-
-
Save h2rd/88989ab473a2dfc05d7d66a458ecc7fa to your computer and use it in GitHub Desktop.
Create a registry secret in Kubernetes
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 | |
rm /tmp/image-pull-secret.yaml | |
login_cmd=$(aws ecr get-login) | |
username=$(echo $login_cmd | cut -d " " -f 4) | |
password=$(echo $login_cmd | cut -d " " -f 6) | |
endpoint=$(echo $login_cmd | cut -d " " -f 9) | |
auth=$(echo "$username:$password" | /usr/bin/base64) | |
configjson="{ \"auths\": { \"${endpoint}\": { \"auth\": \"${auth}\" } } }" | |
kubectl create -f - << EOF | |
apiVersion: v1 | |
kind: Secret | |
metadata: | |
name: aws-ecr-registry | |
data: | |
.dockerconfigjson: $(echo $configjson | /usr/bin/base64) | |
type: kubernetes.io/dockerconfigjson | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment