Amazon EKS AMI Build Specification
This repository contains resources and configuration scripts for building a custom Amazon EKS AMI with HashiCorp Packer. This is the same configuration that Amazon EKS uses to create the official Amazon EKS-optimized AMI.
You must have Packer installed on your local system. For more information, see Installing Packer in the Packer documentation. You must also have AWS account credentials configured so that Packer can make calls to AWS API operations on your behalf. For more information, see Authentication in the Packer documentation.
The default instance type to build this AMI is an
m4.large and does not
qualify for the AWS free tier. You are charged for any instances created
when building this AMI.
Building the AMI
A Makefile is provided to build the AMI, but it is just a small wrapper around invoking Packer directly. You can initiate the build process by running the following command in the root of this repository:
The Makefile runs Packer with the
eks-worker-al2.json build specification
template and the amazon-ebs
builder. An instance is launched and the Packer Shell
Provisioner runs the
install-worker.sh script on the instance to install software and perform other
necessary configuration tasks. Then, Packer creates an AMI from the instance
and terminates the instance after the AMI is created.
Using the AMI
If you are just getting started with Amazon EKS, we recommend that you follow our Getting Started chapter in the Amazon EKS User Guide. If you already have a cluster, and you want to launch a node group with your new AMI, see Launching Amazon EKS Worker Nodes in the Amazon EKS User Guide.
amazon-eks-nodegroup.yaml AWS CloudFormation
template in this repository is provided to launch a node group with the new AMI
ID that is returned when Packer finishes building. Note that there is important
Amazon EC2 user data in this CloudFormation template that bootstraps the worker
nodes when they are launched so that they can register with your Amazon EKS
cluster. Your nodes cannot register properly without this user data.
This sample code is made available under a modified MIT license. See the LICENSE file.