Category: Kubernetes, Terraform

In the last several years, Kubernetes has become the “go to” standard for managing and orchestrating containerized workloads. Thanks to it’s vendor agnostic nature, you can easily run Kubernetes almost anywhere, and in fact, all the major cloud vendors offer a managed Kubernetes service (AWS EKS, Google GKE, and Azure AKS).

When using Kubernetes for a team, you usually want to have an isolated environment for each developer, branch, or pull request.

First we use the following code to authenticate against the Kubernetes cluster that we’ve created and create a new deployment with an ngnix: So now let’s make (and run) a new template using that Terraform code which will create the namespace and run the deployment: Running kubectl to get the namespace and the deployment and we can see the resources we’ve created inside the cluster: You can see that we use the aws_eks_cluster and the aws_eks_cluster_auth data resource to get the authentication data, and to be able to create the namespace and the deployment in the cluster. There is another way to achieve this and import the state file of the Kubernetes cluster you created, but for simplicity we took a simpler approach.

Related Articles