Skip to content

Instantly share code, notes, and snippets.

@sdawood
Created October 9, 2024 15:33
Show Gist options
  • Select an option

  • Save sdawood/243f416e389e1aeeeb86db31a4467160 to your computer and use it in GitHub Desktop.

Select an option

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
#!/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