Commit 41c1c975 authored by Rémy Coutable's avatar Rémy Coutable

Use shared initial passord and license secrets for all Review Apps

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent ad290106
...@@ -26,6 +26,8 @@ gitlab: ...@@ -26,6 +26,8 @@ gitlab:
mailroom: mailroom:
enabled: false enabled: false
migrations: migrations:
initialRootPassword:
secret: shared-gitlab-initial-root-password
resources: resources:
requests: requests:
cpu: 350m cpu: 350m
......
...@@ -195,39 +195,33 @@ function install_external_dns() { ...@@ -195,39 +195,33 @@ function install_external_dns() {
function create_application_secret() { function create_application_secret() {
local namespace="${KUBE_NAMESPACE}" local namespace="${KUBE_NAMESPACE}"
local release="${CI_ENVIRONMENT_SLUG}" local release="${CI_ENVIRONMENT_SLUG}"
local initial_root_password_shared_secret
echoinfo "Creating the ${release}-gitlab-initial-root-password secret in the ${namespace} namespace..." true local gitlab_license_shared_secret
kubectl create secret generic --namespace "${namespace}" \ initial_root_password_shared_secret=$(kubectl get secret --namespace ${namespace} --no-headers -o=custom-columns=NAME:.metadata.name shared-gitlab-initial-root-password | tail -n 1)
"${release}-gitlab-initial-root-password" \ if [[ "${initial_root_password_shared_secret}" == "" ]]; then
--from-literal="password=${REVIEW_APPS_ROOT_PASSWORD}" \ echoinfo "Creating the 'shared-gitlab-initial-root-password' secret in the ${namespace} namespace..." true
--dry-run -o json | kubectl apply -f - kubectl create secret generic --namespace "${namespace}" \
"shared-gitlab-initial-root-password" \
--from-literal="password=${REVIEW_APPS_ROOT_PASSWORD}" \
--dry-run -o json | kubectl apply -f -
else
echoinfo "The 'shared-gitlab-initial-root-password' secret already exists in the ${namespace} namespace."
fi
if [ -z "${REVIEW_APPS_EE_LICENSE}" ]; then echo "License not found" && return; fi if [ -z "${REVIEW_APPS_EE_LICENSE}" ]; then echo "License not found" && return; fi
echoinfo "Creating the ${release}-gitlab-license secret in the ${namespace} namespace..." true gitlab_license_shared_secret=$(kubectl get secret --namespace ${namespace} --no-headers -o=custom-columns=NAME:.metadata.name shared-gitlab-license | tail -n 1)
if [[ "${gitlab_license_shared_secret}" == "" ]]; then
echo "${REVIEW_APPS_EE_LICENSE}" > /tmp/license.gitlab echoinfo "Creating the 'shared-gitlab-license' secret in the ${namespace} namespace..." true
echo "${REVIEW_APPS_EE_LICENSE}" > /tmp/license.gitlab
kubectl create secret generic --namespace "${namespace}" \ kubectl create secret generic --namespace "${namespace}" \
"${release}-gitlab-license" \ "shared-gitlab-license" \
--from-file=license=/tmp/license.gitlab \ --from-file=license=/tmp/license.gitlab \
--dry-run -o json | kubectl apply -f - --dry-run -o json | kubectl apply -f -
} else
echoinfo "The 'shared-gitlab-license' secret already exists in the ${namespace} namespace."
function label_application_secret() { fi
local namespace="${KUBE_NAMESPACE}"
local release="${CI_ENVIRONMENT_SLUG}"
echoinfo "Labeling the ${release}-gitlab-initial-root-password and ${release}-gitlab-license secrets in the ${namespace} namespace..." true
kubectl label secret --namespace "${namespace}" \
"${release}-gitlab-initial-root-password" \
release="${release}"
kubectl label secret --namespace "${namespace}" \
"${release}-gitlab-license" \
release="${release}"
} }
function download_chart() { function download_chart() {
...@@ -270,7 +264,6 @@ function deploy() { ...@@ -270,7 +264,6 @@ function deploy() {
gitlab_workhorse_image_repository="${IMAGE_REPOSITORY}/gitlab-workhorse-${edition}" gitlab_workhorse_image_repository="${IMAGE_REPOSITORY}/gitlab-workhorse-${edition}"
create_application_secret create_application_secret
label_application_secret
HELM_CMD=$(cat << EOF HELM_CMD=$(cat << EOF
helm upgrade \ helm upgrade \
...@@ -306,7 +299,7 @@ EOF ...@@ -306,7 +299,7 @@ EOF
if [ -n "${REVIEW_APPS_EE_LICENSE}" ]; then if [ -n "${REVIEW_APPS_EE_LICENSE}" ]; then
HELM_CMD=$(cat << EOF HELM_CMD=$(cat << EOF
${HELM_CMD} \ ${HELM_CMD} \
--set global.gitlab.license.secret="${release}-gitlab-license" --set global.gitlab.license.secret="shared-gitlab-license"
EOF EOF
) )
fi fi
......
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