Created
April 20, 2017 04:48
-
-
Save olalonde/1dd5c572e3329fbae0a5a434709c45a6 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