Skip to content

Instantly share code, notes, and snippets.

@metral
Created August 30, 2017 05:47
Show Gist options
  • Save metral/2c65a0732b51b69a616a6726b4e1a7cc to your computer and use it in GitHub Desktop.
Save metral/2c65a0732b51b69a616a6726b4e1a7cc to your computer and use it in GitHub Desktop.
k8s registry creds
#!/bin/bash
AUTH="$DOCKER_USERNAME:$DOCKER_PASSWORD"
AUTH_B64=$(echo -n $AUTH | base64 -w 0)
DOCKERCFG="{
\"auths\": {
\"$DOCKER_REGISTRY\": {
\"auth\": \"$AUTH_B64\"
}
}
}
"
DOCKERCFG_B64=`echo -n $DOCKERCFG | base64 -w 0`
cat > registry-creds.yaml << EOF
apiVersion: v1
kind: Secret
metadata:
name: registry-creds
data:
.dockerconfigjson: ${DOCKERCFG_B64}
type: kubernetes.io/dockerconfigjson
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment