Terraform, why use kubernetes as a extra layer?

4/5/2020

I read a lot of documents on the internet. They describe the best combination is Terraform and Kubernetes. Use Terraform for provisioning and Kubernetes for pod management

If I need to scale then I say to Terraform add new containers. So why Kubernetes ? Is it more as a monitoring tool in this case, Kubernetes? I mean I can't say to Kubernetes I need more containers it will get in conflict with Terraform.

I don't understand why use the extra layer of Kubernetes.

-- F T
kubernetes
terraform

1 Answer

4/5/2020

Terraform is a tool for provisioning infrastructure across cloud providers, that lets you describe the infrastructure you would like to provision as code (Infrastructure as Code or IaC). You run it, infrastructure is provisioned and that's it.

On the other hand, Kubernetes is a container orchestration engine. It orchestrates worker nodes, where pods are scheduled. It takes decisions on:

  • Scheduling: Where the pods should be scheduled to make sure that their resource (CPU / RAM) requests are satisfied
  • Service discovery: How one service can communicate with another one
  • Self healing: Takes action when a pod is not healthy and restarts it. In addition, it takes action if a worker node is not healthy.
  • Autoscaling: Automatically provisions new replicas when the load for your service is high
  • Version rollouts: How new versions are deployed and old versions are terminated

These are just some of the features of Kubernetes, and you can check for more of its features in the "Kubernetes Features" section of this page.

Terraform can help you provision your infrastructure, but when your workloads are container-based, then you need a container orchestrator. This is where Kubernetes fits in.

-- George Tseres
Source: StackOverflow