How to Deploy to Amazon EKS With kubectl in CircleCI
Run aws eks update-kubeconfig to write cluster credentials, then kubectl apply and kubectl rollout status to ship and confirm the deploy.
Authenticate to EKS by writing a kubeconfig with aws eks update-kubeconfig, set the new image, and block on kubectl rollout status.
Steps
- Install
kubectland the AWS CLI in the executor. - Run
aws eks update-kubeconfig --name <cluster>. - Set the deployment image to the freshly built tag.
- Wait for
kubectl rollout statusto confirm success.
Config
.circleci/config.yml
version: 2.1
jobs:
deploy:
docker:
- image: cimg/aws:2024.03
steps:
- checkout
- run:
name: Configure kubeconfig
command: aws eks update-kubeconfig --name "$EKS_CLUSTER" --region "$AWS_REGION"
- run:
name: Roll out new image
command: |
kubectl set image deployment/api \
api="$ECR_REPO:$CIRCLE_SHA1" -n production
kubectl rollout status deployment/api -n production --timeout=120s
workflows:
ship:
jobs:
- deploy:
context: aws-prodGotchas
- The IAM identity must be in the cluster
aws-authConfigMap or the access entries, orkubectlreturns a 401. rollout statusexits non-zero on timeout, which fails the job so a stuck deploy does not pass silently.
Related guides
How to Deploy With Helm in CircleCIDeploy a Kubernetes app from CircleCI with helm upgrade --install, pinning the chart, overriding the image ta…
How to Deploy to EKS With the aws-eks Orb in CircleCIDeploy a Kubernetes manifest to Amazon EKS from CircleCI with the aws-eks orb, which configures kubectl and a…