Created
May 2, 2020 01:00
-
-
Save ibonkonesa/379e6b1daadb2a61c53674f26021fcf9 to your computer and use it in GitHub Desktop.
Create docker private registry ui and repository users
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 | |
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
This script create/update user in kubernetes private docker registry and catalog (registry-ui)
-Docker registry (secret is called docker-registry-secret) https://github.com/helm/charts/tree/master/stable/docker-registry
-Docker registry ui (custom deploy. Secret is called catalog-registry-auth ) https://hub.docker.com/r/joxit/docker-registry-ui/