Commit 1d686941 authored by Dmytro Bogatov's avatar Dmytro Bogatov 💕

Add basic auth to docker image.

parent 1cd7b68e
Pipeline #3103 passed with stages
in 49 seconds
......@@ -7,12 +7,12 @@ cd "${0%/*}"
CWD=$(pwd)
usage () {
printf "usage: $0 <name> <image> <url>\n"
printf "usage: $0 <name> <image> <url> <auth-password>\n"
exit 1;
}
if ! [ $# -eq 3 ]
if ! [ $# -eq 4 ]
then
usage
fi
......@@ -20,6 +20,9 @@ fi
NAME=$1
IMAGE=$2
URL=$3
AUTHPASS=$4
AUTH=""
echo "Generating $NAME configs..."
......@@ -37,8 +40,16 @@ digest="${digest%\"}"
digest="${digest#\"}"
IMAGE=${IMAGE%:*}@$digest
if [ "$AUTHPASS" != "" ]
then
AUTH="nginx.ingress.kubernetes.io/auth-type: basic"
fi
htpasswd -b -c ./out/auth review $AUTHPASS
sed -i -e "s#__IMAGE__#$IMAGE#g" ./out/{service,deployment,ingress}.yaml
sed -i -e "s#__NAME__#$NAME#g" ./out/{service,deployment,ingress}.yaml
sed -i -e "s#__URL__#$URL#g" ./out/{service,deployment,ingress}.yaml
sed -i -e "s#__AUTH__#$AUTH#g" ./out/{service,deployment,ingress}.yaml
rm -rf ./out/*-e
......@@ -7,6 +7,9 @@ metadata:
kubernetes.io/ingress.class: "public"
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/auth-secret: __NAME__-basic-auth
nginx.singress.kubernetes.io/auth-realm: "The username is 'review' (without quotes) and the password is .gitlab-ci.yml file on the top in variable AUTHPASSWORD."
__AUTH__
spec:
tls:
- secretName: lets-encrypt
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment