Automating the creation of fully fledged Kubernetes clusters in Amazon (AWS EKS)

With Kubernetes gaining traction, more and more teams are looking to use it. Recently, AWS announced the release of the Amazon EKS (Elastic Kubernetes Service), which means we can now deploy Kubernetes in AWS, more-or-less as a managed service. I say more or less because AWS takes good care of managing the Kubernetes control plane (the master nodes), but you have to manage the worker nodes (which you can launch as EC2 instances in one ore more Auto Scale Groups).

Launching an AWS EKS cluster has quite a few steps, since you have to first create a VPC, subnets, IAM roles and other AWS resources.

Simplifying Kubernetes cluster creation in AWS EKS

In order to quickly spin up Kubernetes clusters (in a repeatable and automated fashion), we can use an open source tool created by Adobe named ops-cli, along with Terraform from HashiCorp. Terraform supports deploying a Kubernetes cluster in AWS (via what’s called an Amazon Elastic Kubernetes service). We are using ops-cli to perform templating of this AWS EKS terraform module, so that we can re-use it. This allows us to deploy multiple Kubernetes clusters, across different regions/environments.

Once the Kubernetes cluster is up and running, we want to install some common packages before deploying our own apps. These can include: cluster-autoscaler, logging (eg. Fluentd), metrics (eg. Prometheus), tracing (eg. New Relic), continuous deployment (eg. Spinnaker) and so forth. Luckily, these are all already available, packaged as Helm charts (https://github.com/helm/charts/tree/master/stable).

What’s nice about this, is that we can use Terraform to deploy Helm charts inside our newly created Kubernetes cluster. This can be achieved via the Helm Terraform provider (https://github.com/terraform-providers/terraform-provider-helm). The ops-cli is handy in order to minimize code duplication when deploying these common helm packages via Terraform.

There’s a fully working example on the Adobe GitHub page, which deploys a Kubernetes cluster in AWS using ops-cli + terraform + helm, along with the aforementioned services inside the Kubernetes cluster itself: https://github.com/adobe/ops-cli/tree/master/examples/aws-kubernetes

Leave a comment

Create a free website or blog at WordPress.com.

Up ↑