ECR Token automation for Kubernetes cluster
ECR-Token-automation
aws ecr login token automation to kubernetes secrets
This shell script will make kubermetes secrets which will use to pull docker images from aws ECR.
Secret will contain login information of
Secret will contain login information of AWS ECR
Secret will contain login information of AWS ECR
For code : Click here ...!
https://github.com/harsh4870/ECR-Token-automation
ACCOUNT=123456789 #aws account number
REGION=ap-south-1 #aws ECR region
SECRET_NAME=${REGION}-ecr-registry #secret_name
EMAIL=abc@xyz.com #can be anything
TOKEN=`aws ecr --region=$REGION get-authorization-token --output text --query authorizationData[].authorizationToken | base64 -d | cut -d: -f2`
kubectl delete secret --ignore-not-found $SECRET_NAME
kubectl create secret docker-registry $SECRET_NAME \
--docker-server=https://$ACCOUNT.dkr.ecr.ap-south-1.amazonaws.com \
--docker-username=AWS \
--docker-password="${TOKEN}" \
--docker-email="${EMAIL}"
Comments
Post a Comment