Karpenter re:Invent 2021 Builders Session
Prerequisites
Please install the following tools before starting:
- AWS CLI. If you’re on macOS and have Homebrew installed, simply
brew install awscli
. Otherwise, follow the AWS CLI user’s guide. - Helm, the Kubernetes package manager. If you’re on macOS, feel free to simply
brew install helm
. Otherwise, follow the Helm installation guide.
Get Started
Once you have all the necessary tools installed, configure your shell with the credentials for the temporary AWS account created for this session by:
- Navigating to the Event Engine team dashboard and clicking on the “☁️ AWS Console” button
- Configuring your shell with the credentials required by copy and pasting the command for your operating system.
- Running the following to set your
AWS_ACCOUNT_ID
environmental variable:export AWS_ACCOUNT_ID="$(aws sts get-caller-identity --query Account --output text)"
- Updating your local Kubernetes configuration (
kubeconfig
) by running:aws eks update-kubeconfig --name karpenter-demo --role-arn arn:aws:iam::${AWS_ACCOUNT_ID}:role/KarpenterEESetupRole-karpenter-demo
- Creating an AWS IAM service-linked role so that Karpenter can provision Spot EC2 instances with the following command:
aws iam create-service-linked-role --aws-service-name spot.amazonaws.com
N.B. If the role was created previously, you will see:
# An error occurred (InvalidInput) when calling the CreateServiceLinkedRole operation: Service role name AWSServiceRoleForEC2Spot has been taken in this account, please try a different suffix.
If you can run the following command and see the pods running in your EKS cluster, you’re all set! If not, please ask for help from one of the speakers in the session and they’ll get you squared away. For your reference, the cluster name is karpenter-demo
.
kubectl get pods -A
Congratulations! You now have access to an Amazon EKS cluster with an EKS Managed Node Group as well as all the AWS infrastructure necessary to use Karpenter. Happy Building 🔨!
Install Karpenter
Use the following command to install Karpenter into your cluster:
helm repo add karpenter https://charts.karpenter.sh
helm repo update
helm upgrade --install karpenter karpenter/karpenter --namespace karpenter \
--create-namespace --set serviceAccount.create=false --version 0.5.3 \
--set controller.clusterName=karpenter-demo \
--set controller.clusterEndpoint=$(aws eks describe-cluster --name karpenter-demo --query "cluster.endpoint" --output json) \
--wait # for the defaulting webhook to install before creating a Provisioner
Next Steps
If you’re a Kubernetes expert, feel free to start exploring how Karpenter works on your own and if you have any questions, one of the AWS speakers will be happy to answer them. If you’d like a guided walkthrough of Karpenter’s features and capabilities, you can follow the Karpenter Getting Started guide starting at the “Provisioner” step. Please don’t hesitate to ask your AWS speaker any questions you might have!