Created
October 9, 2024 15:33
-
-
Save sdawood/243f416e389e1aeeeb86db31a4467160 to your computer and use it in GitHub Desktop.
Refresh AWS ECR token and update imagePullSecret for minikube local Deployment of AWS ECR hosted container images
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/bash | |
| ACCOUNT_ID=$AWS_ACCOUNT_ID | |
| REGION=$AWS_REGION | |
| aws ecr get-login-password --region ${REGION} | docker login --username AWS --password-stdin "${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com" | |
| dockerconfigjson=$(cat ~/.docker/config.json | base64 -w0) | |
| # This local minikube secret should be used as imagePullSecret in Deployment manifests applied to minikube | |
| # | |
| # spec: | |
| # imagePullSecrets: | |
| # - name: awsecr-cred-secret | |
| # | |
| # | |
| kubectl replace --force -f - <<END | |
| apiVersion: v1 | |
| kind: Secret | |
| metadata: | |
| name: awsecr-cred-secret | |
| type: kubernetes.io/dockerconfigjson | |
| data: | |
| .dockerconfigjson: | | |
| $dockerconfigjson | |
| END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment