Add/fix namespace scripts to handle docker pull secrets and linkerd
This commit is contained in:
76
scripts/install-namespace.sh
Executable file
76
scripts/install-namespace.sh
Executable file
@@ -0,0 +1,76 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set +e
|
||||
|
||||
TOP="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
|
||||
|
||||
if [ x$1 = x ]; then
|
||||
ehco "usage: install-namespace.sh {namespace|all}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
namespace=$1
|
||||
|
||||
setup_namespace () {
|
||||
local namespace
|
||||
namespace=$1
|
||||
cat << EOF | kubectl apply -f -
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
annotations:
|
||||
linkerd.io/inject: enabled
|
||||
labels:
|
||||
name: $namespace
|
||||
name: $namespace
|
||||
EOF
|
||||
}
|
||||
|
||||
create_docker_secret () {
|
||||
local namespace
|
||||
namespace=$1
|
||||
kubectl get secret docker-pull-secret -n $namespace >/dev/null 2>&1
|
||||
[ $? = 0 ] && kubectl delete secret docker-pull-secret -n $namespace
|
||||
|
||||
kubectl create secret docker-registry docker-pull-secret \
|
||||
-n $namespace \
|
||||
--docker-username=juselius \
|
||||
--docker-password=ed584a31-c7ff-47ba-8469-3f0f4db6402c \
|
||||
--docker-email=jonas.juselius@gmail.com
|
||||
}
|
||||
|
||||
create_gitlab_secret () {
|
||||
local namespace
|
||||
namespace=$1
|
||||
cat << EOF | kubectl apply -f -
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: gitlab-pull-secret
|
||||
namespace: $namespace
|
||||
kind: Secret
|
||||
type: kubernetes.io/dockerconfigjson
|
||||
data:
|
||||
.dockerconfigjson: ewoJImF1dGhzIjogewoJCSJyZWdpc3RyeS5naXRsYWIuY29tIjogewoJCQkiYXV0aCI6ICJaMmwwYkdGaUsyUmxjR3h2ZVMxMGIydGxiaTB4T1Rnd01qQTZPRmxqU0VoMFZIaENSVUZUTFZKUWRsSnJXbGM9IgoJCX0KCX0sCgkiSHR0cEhlYWRlcnMiOiB7CgkJIlVzZXItQWdlbnQiOiAiRG9ja2VyLUNsaWVudC8xOS4wMy4xMiAobGludXgpIgoJfQp9Cg==
|
||||
EOF
|
||||
}
|
||||
|
||||
inject_pull_secrets () {
|
||||
local namespace
|
||||
namespace=$1
|
||||
$TOP/inject-sa-pull-secrets.sh $namespace all
|
||||
}
|
||||
|
||||
configure_namespace () {
|
||||
setup_namespace $1
|
||||
create_docker_secret $1
|
||||
create_gitlab_secret $1
|
||||
inject_pull_secrets $1
|
||||
}
|
||||
|
||||
if [ "x$namespace" = "xall" ]; then
|
||||
for i in $(kubectl get ns | sed '1d; s/\([^ ]\+\).*/\1/'); do
|
||||
configure_namespace $i
|
||||
done
|
||||
else
|
||||
configure_namespace $namespace
|
||||
fi
|
||||
Reference in New Issue
Block a user