Browse the Repo

file-type-icondata-stores
file-type-iconlambda
file-type-iconmgmt
file-type-iconnetworking
file-type-iconsecurity
file-type-iconservice-templates
file-type-iconservices
file-type-iconasg-service
file-type-iconbeanstalk-service
file-type-iconecs-cluster
file-type-iconecs-service-with-alb
file-type-iconeks-cluster
file-type-iconmigration_guides
file-type-iconpacker
file-type-iconuser-data
file-type-iconREADME.md
file-type-icondependencies.tf
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconvariables.tf
file-type-iconeks-core-services
file-type-iconk8s-namespace
file-type-iconk8s-service
file-type-iconstatic-website
file-type-icontls-scripts
file-type-icon.gitignore
file-type-iconCODEOWNERS
file-type-iconREADME.md

Browse the Repo

file-type-icondata-stores
file-type-iconlambda
file-type-iconmgmt
file-type-iconnetworking
file-type-iconsecurity
file-type-iconservice-templates
file-type-iconservices
file-type-iconasg-service
file-type-iconbeanstalk-service
file-type-iconecs-cluster
file-type-iconecs-service-with-alb
file-type-iconeks-cluster
file-type-iconmigration_guides
file-type-iconpacker
file-type-iconuser-data
file-type-iconREADME.md
file-type-icondependencies.tf
file-type-iconmain.tf
file-type-iconoutputs.tf
file-type-iconvariables.tf
file-type-iconeks-core-services
file-type-iconk8s-namespace
file-type-iconk8s-service
file-type-iconstatic-website
file-type-icontls-scripts
file-type-icon.gitignore
file-type-iconCODEOWNERS
file-type-iconREADME.md
Sample Infrastructure Modules

Sample Infrastructure Modules

Sample infrastructure-modules repo (multi-account setup) for fictional company Acme.

Code Preview

Preview the Code

mobile file icon

README.md

down

EKS Cluster Module

This Terraform Module launches an Elastic Container Service for Kubernetes Cluster that you can use to run Docker containers. The cluster consists of a configurable number of instances in an Auto Scaling Group (ASG). Each instance:

  1. Runs the kubelet process so it can communicate with the Kubernetes control plane.
  2. Emits custom metrics that are not available by default in CloudWatch, including memory and disk usage. This is configured using the cloudwatch-memory-disk-metrics-scripts module.
  3. Runs the ssh-grunt module so that developers can upload their public SSH keys to IAM and use those SSH keys, along with their IAM user names, to SSH to the EKS Nodes.
  4. Runs the auto-update module so that the EKS nodes install security updates automatically.

How do you use this module?

  1. Build the AMI
  2. Make sure kubergrunt is in your path.
  3. Deploy the Terraform code

Build the AMI

Each EC2 instance in the EKS cluster should run an AMI built using the Packer template in packer/eks-node.json. To build the AMI:

  1. Install Packer.
  2. Set your AWS credentials as the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
  3. Set your GitHub access token as the environment variable GITHUB_OAUTH_TOKEN. Your GitHub account must have access to the Gruntwork GitHub repos mentioned in packer/eks-node.json; if you don't have access to those, email support@gruntwork.io.
  4. Run packer build eks-node.json.
  5. When the build completes, it'll output the id of the new AMI.

Deploy the Terraform code

  • See the root README for instructions on how to deploy the Terraform code in this repo.
  • See variables.tf for all the variables you can set on this module.

What is an EKS Cluster?

To use EKS, you first provision an EKS cluster, which acts as the managed AWS Kubernetes Control Plane. You then provision one or more EC2 Instances to act as workers for the cluster. The Kubernetes scheduler can then deploy Docker containers across any of the instances in this cluster. Each instance needs to have the kubelet process installed so it can communicate with the Kubernetes control plane and register itself as part of the right cluster.

Core concepts

For more info on EKS clusters, including how to run Docker containers in a cluster, how to add additional security group rules, how to handle IAM policies, and more, check out the eks-cluster-control-plane documentation and the eks-cluster-workers documentation in the terraform-aws-eks repo. The following are is a list of links to specific sections regarding various concepts:

Questions? Ask away.

We're here to talk about our services, answer any questions, give advice, or just to chat.

Ready to hand off the Gruntwork?