-
-
Save arcanoix/9f8110119f149915cfeb72e2cd684cf6 to your computer and use it in GitHub Desktop.
Create docker private registry ui and repository users
This file contains 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 | |
username=$1; | |
password=$2; | |
#CREATE USER IN REGISTRY | |
docker run --rm -it -v $(pwd):/data httpd htpasswd -Bb /data/registrypasswords $username $password | |
#CREATE USER IN CATALOG | |
docker run --rm -it -v $(pwd):/data httpd htpasswd -b /data/auth $username $password | |
#UPDATE REGISTRY USERS | |
pass=`cat registrypasswords| base64 -w 0` | |
sed "s/^\(\s*htpasswd\s*:\s*\).*/\1 ${pass}/" secret.yaml > deploy.yaml | |
#REMOVE OLD REGISTRY SECRET | |
kubectl delete secret docker-registry-secret | |
#ADD REGISTRY SECRET | |
kubectl apply -f deploy.yaml | |
#REMOVE OLD CATALOG SECRET | |
kubectl delete secret catalog-registry-auth | |
#ADD CATALOG AUTH SECRET | |
kubectl create secret generic catalog-registry-auth --from-file=auth | |
#UPDATE REGISTRY LOCAL SECRET TO GET IT UPDATED | |
cp deploy.yaml secret.yaml | |
#RESTART REGISTRY POD | |
podName=`kubectl get pods | grep docker-registry | awk '{ print $1 }'` | |
kubectl delete pod $podName |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment