Skip to content

Instantly share code, notes, and snippets.

@gadiener
Created December 5, 2019 16:33
Show Gist options
  • Save gadiener/4f7e7c9e19f6dc65a8695cd004e4f7d2 to your computer and use it in GitHub Desktop.
Save gadiener/4f7e7c9e19f6dc65a8695cd004e4f7d2 to your computer and use it in GitHub Desktop.
Create docker-registry secret file
#!/bin/sh
set -e
if [ -n "${DEBUG}" ]; then
set -x
fi
for var in "DOCKER_USERNAME" "DOCKER_PASSWORD" "DOCKER_EMAIL"; do
if [ -z "${!var}" ]; then
echo "Missing '${var}' variable!"
exit 1
fi
done
if [ -z "${DOCKER_SERVER}" ]; then
DOCKER_SERVER=https://hub.docker.com/v2/
fi
if [ -z "${SECRET_NAME}" ]; then
SECRET_NAME=registry-credentials
fi
echo
echo "-> Generating docker secret:"
echo
kubectl create secret docker-registry \
"${SECRET_NAME}" \
--docker-server="${DOCKER_SERVER}" \
--docker-username="${DOCKER_USERNAME}" \
--docker-password="${DOCKER_PASSWORD}" \
--docker-email="${DOCKER_EMAIL}" \
-o yaml \
--dry-run
echo
echo "-> Secret generated!"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment