Browse the Repo

file-type-icon.circleci
file-type-icon.github
file-type-icon_docs
file-type-iconexamples
file-type-iconmodules
file-type-iconrfc
file-type-icontest
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-iconCODEOWNERS
file-type-iconCONTRIBUTING.md
file-type-iconGRUNTWORK_PHILOSOPHY.md
file-type-iconLICENSE.md
file-type-iconREADME.adoc
file-type-iconcore-concepts.md
file-type-icongetting-started.md
file-type-icongruntwork-gitops.md
file-type-iconrenovate.json
file-type-iconsetup.cfg
file-type-iconterraform-cloud-enterprise-private-module-...

Browse the Repo

file-type-icon.circleci
file-type-icon.github
file-type-icon_docs
file-type-iconexamples
file-type-iconmodules
file-type-iconrfc
file-type-icontest
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-iconCODEOWNERS
file-type-iconCONTRIBUTING.md
file-type-iconGRUNTWORK_PHILOSOPHY.md
file-type-iconLICENSE.md
file-type-iconREADME.adoc
file-type-iconcore-concepts.md
file-type-icongetting-started.md
file-type-icongruntwork-gitops.md
file-type-iconrenovate.json
file-type-iconsetup.cfg
file-type-iconterraform-cloud-enterprise-private-module-...
EC2 Kubernetes Service (EKS) Cluster

EC2 Kubernetes Service (EKS) Cluster

Deploy a Kubernetes cluster on top of Amazon EC2 Kubernetes Service (EKS).

Code Preview

Preview the Code

mobile file icon

getting-started.md

down

Getting Started

The terraform-aws-eks repo contains a collection of Terraform modules for deploying an AWS EKS cluster and additional supporting resources. The primary tool that is used for deploying these resources is Terraform. However, there are a number of additional tools that are required to work with the terraform-aws-eks repo (and the Gruntwork Library in general). All tools listed below should be installed and properly configured prior to attempting to deploy any of the modules within the terraform-aws-eks repo.

Tool Description
Terraform Recommended to be installed and managed via tfenv to easily install multiple versions of Terraform and easily switch between versions as needed.
Terragrunt Only needed if following the Terragrunt workflow.
AWS CLI v2 Required tool for using Terraform with AWS.
Python Recommended to be installed and managed via pyenv to easily install multiple versions of Python and easily switch between versions as needed.
kubergrunt EKS module has dependencies on kubergrunt. Will be installed automatically if not present on system, but it is better to have this pre-installed to avoid any potential issues during Terraform runs.
Packer Packer is used for building the Gruntwork EKS Worker AMI.

Tool Configuration

Once each of the recommended tools are installed, it is important to have each of them properly configured. The most common configuration issues arise from the AWS CLI and Python. Below are configuration considerations and recommendations on the AWS CLI and Python.

AWS CLI

There are multiple methods for configuring the AWS CLI. A recommended approach is to configure the AWS CLI using named profiles for each of the environments you will be working with, then setting environment variables that specify the appropriate profile based on the environment you are executing against.

This is a great blog on securing and authenticating with the AWS CLI for reference.

Example AWS CLI configuration with IAM User and IAM Role

# ~/.aws/config
[profile my-user]
region = us-east-1
output = json
cli_pager =

[profile my-assumed-role]
role_arn = arn:aws:iam::1234567891011:role/MyRole
source_profile = my-user
output = json
region = us-east-1
cli_pager =

# ~/.aws/credentials
[my-user]
aws_access_key_id = ABCDEFJ1234567
aws_secret_access_key = asdfasdfadsfasdfasdfasdfadsf

# Environment variables set on machine
AWS_PROFILE=my-assumed-role

# Make sure to unset AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY

Complimentary Tools

  • aws-vault is a great tool for securely storing credentials locally on the machine and is an alternative to using local configuration files which store credentials in plain text.

Python

Many systems come with Python pre-installed but the system installed version isn't recommended to be used outside of the core system function. It is typically better to explicitly install the needed version(s) of Python in addition to the system pre-installed version. Using a tool like pyenv can help proper installation of Python, including multiple versions, and is recommended. Python 3 is a requirement for the Gruntwork Library and python should resolve to Python 3, not Python 2.

Common Issues

  • Python not found on PATH
  • python command resolves to Python 2 and not Python 3

Common Resolutions


EKS Worker Node AMI

An important, and often missed, pre-requisite for deploying an AWS EKS cluster with the terraform-aws-eks repo/module, is building the EKS Worker Node AMI. The terraform-aws-eks repo/module was not designed to work with off-the-shelf AMIs provided by AWS or the broader community. Support for this may come at a later date, but as of now building the Gruntwork EKS Worker Node AMI is a pre-requisite requirement for running EKS via the terraform-aws-eks repo/module. The exception to this is if running a Fargate only EKS Cluster. The reason for this requirement is there are a number of additional components built into the AMI as dependencies that provide additional hardening to the Worker Node and provide additional mechanisms for managing the lifecycle of the EKS Worker Node itself.

The Gruntwork Worker Node AMI is built via a provided Packer template. The template can be found here. Instructions on how to build the AMI are provided in the README.

NOTE: When building the AMI from the template, ensure that the input variables provided are appropriate for the intended use. Such as the AWS Region the AMI should be available in and the version of Kubernetes the EKS cluster will be running.

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?