-
-
Save saviour123/17b4c3bcd11d09949c50a388307bc9b6 to your computer and use it in GitHub Desktop.
argocd-ecr-rotating-key
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
namespaces="${NAMESPACES}" | |
if [ -z "$NAMESPACES" ]; then | |
namespaces="default" | |
fi | |
if [ -z "$SECRET_NAME" ]; then | |
SECRET_NAME=regcred | |
fi | |
TOKEN=`aws ecr get-login-password --region ${AWS_REGION}` | |
for namespace in $namespaces; do | |
echo "Updating ecr token to namespace: $namespace" | |
kubectl delete secret -n $namespace --ignore-not-found $SECRET_NAME | |
kubectl create secret -n $namespace docker-registry $SECRET_NAME \ | |
--docker-server=$ECR_REPOSITORY \ | |
--docker-username=AWS \ | |
--docker-password=$TOKEN \ | |
--namespace=$namespace | |
kubectl patch serviceaccount default -p '{"imagePullSecrets":[{"name":"'$SECRET_NAME'"}]}' -n $namespace | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment