Deploy to EKS cluster from CodeBuild
-
In the buildspec.yaml, change the kubectl binary version and EKS cluster region and Cluster name to match with your EKS cluster (currently it uses EKS v1.15)
-
Allow CodeBuild Service IAM role in aws-auth ConfigMap
- kubectl -n kube-system edit cm aws-auth
- Add CodeBuild service IAM role under mapRoles section:
mapRoles: |
- groups:
- system:masters
rolearn: arn:aws:iam:123456789012:role/KubernetesRole #<---- codebuild is assuming this IAM role
username: KubernetesRole
- Create a CodeBuild project with following configs to deploy the pod/application on every push/pull request
- Github source provider
- Webhook\
- Add 3 env-variables: ECR_REPO_URI, EKS_CLUSTER_NAME, EKS_VERSION