Skip to content

Instantly share code, notes, and snippets.

@asrail
Forked from AmitDJagtap/ecr-cred-refresh-1.yml
Last active August 23, 2021 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asrail/7c72257ab34ba68002b416238e57206b to your computer and use it in GitHub Desktop.
Save asrail/7c72257ab34ba68002b416238e57206b to your computer and use it in GitHub Desktop.
apiVersion: v1
stringData:
AWS_ACCESS_KEY_ID: put your access key ID here
AWS_SECRET_ACCESS_KEY: put your secret access key here. You can use any "safe" form for secret management
kind: Secret
metadata:
name: aws-creds
type: Opaque
---
apiVersion: v1
kind: Pod
metadata:
name: ecr-cred-helper
spec:
containers:
- command:
- /bin/sh
- -c
- |-
kubectl delete secret --ignore-not-found $SECRET_NAME
kubectl create secret docker-registry $SECRET_NAME \
--docker-server=https://${ACCOUNT}.dkr.ecr.${AWS_REGION}.amazonaws.com \
--docker-username=AWS \
--docker-password=$(aws ecr get-login-password --region $AWS_REGION)
env:
- name: AWS_REGION
value: us-east-1
- name: SECRET_NAME
value: regcred
- name: ACCOUNT
value: "##############"
envFrom:
- secretRef:
name: aws-creds
image: place your **public** image with kubectl and AWS CLI v2
imagePullPolicy: IfNotPresent
name: ecr-cred-helper
restartPolicy: Never
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment