Skip to content

Instantly share code, notes, and snippets.

@nibalizer
Created June 29, 2019 21:16
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 nibalizer/36fb6a72cc3e48fe609392d37a12f339 to your computer and use it in GitHub Desktop.
Save nibalizer/36fb6a72cc3e48fe609392d37a12f339 to your computer and use it in GitHub Desktop.
script (from andreaf) to auth to ibm cloud registry using ko
ibmcloud login
ibmcloud cr login
REGISTRY_ENDPOINT=$(ibmcloud cr info | awk '/Registry/{ print $3 }' | head -1)
# Create a CR token with write access
CR_TOKEN=$(ibmcloud cr token-add --readwrite --description ko_rw --non-expiring -q)
# Backup your docker config if you have one
cp ~/.docker/config.json ~/.docker/config.json.$(date +%F)
# Setup docker auth so it may talk to the CR.
echo '{"auths":{"'$REGISTRY_ENDPOINT'":{"auth":"'$(echo -n token:$CR_TOKEN | base64 -w0)'"}}}' | jq '.' > ~/.docker/config.json
# Create a CR namespace
CR_NAMESPACE=knative
ibmcloud cr namespace-add $CR_NAMESPACE
# Configure ko
KO_DOCKER_REPO=$REGISTRY_ENDPOINT/$CR_NAMESPACE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment