2018-09-25 10:32:53 -04:00
|
|
|
[[ "$TRACE" ]] && set -x
|
|
|
|
|
2019-05-23 10:37:29 -04:00
|
|
|
function deploy_exists() {
|
2019-03-27 05:36:01 -04:00
|
|
|
local namespace="${1}"
|
2019-11-21 13:06:26 -05:00
|
|
|
local release="${2}"
|
|
|
|
local deploy_exists
|
2019-03-27 05:36:01 -04:00
|
|
|
|
2019-11-21 13:06:26 -05:00
|
|
|
echoinfo "Checking if ${release} exists in the ${namespace} namespace..." true
|
2019-03-27 05:36:01 -04:00
|
|
|
|
2020-04-07 14:09:19 -04:00
|
|
|
helm status --namespace "${namespace}" "${release}" >/dev/null 2>&1
|
2019-11-21 13:06:26 -05:00
|
|
|
deploy_exists=$?
|
|
|
|
|
|
|
|
echoinfo "Deployment status for ${release} is ${deploy_exists}"
|
2019-03-27 05:36:01 -04:00
|
|
|
return $deploy_exists
|
|
|
|
}
|
|
|
|
|
2019-05-23 10:37:29 -04:00
|
|
|
function previous_deploy_failed() {
|
2019-11-21 13:06:26 -05:00
|
|
|
local namespace="${1}"
|
|
|
|
local release="${2}"
|
|
|
|
|
|
|
|
echoinfo "Checking for previous deployment of ${release}" true
|
2019-03-27 05:36:01 -04:00
|
|
|
|
2020-04-07 14:09:19 -04:00
|
|
|
helm status --namespace "${namespace}" "${release}" >/dev/null 2>&1
|
2019-03-27 05:36:01 -04:00
|
|
|
local status=$?
|
|
|
|
|
|
|
|
# if `status` is `0`, deployment exists, has a status
|
|
|
|
if [ $status -eq 0 ]; then
|
|
|
|
echoinfo "Previous deployment found, checking status..."
|
2020-04-07 14:09:19 -04:00
|
|
|
deployment_status=$(helm status --namespace "${namespace}" "${release}" | grep ^STATUS | cut -d' ' -f2)
|
2019-03-27 05:36:01 -04:00
|
|
|
echoinfo "Previous deployment state: ${deployment_status}"
|
2020-04-07 14:09:19 -04:00
|
|
|
if [[ "$deployment_status" == "failed" || "$deployment_status" == "pending-upgrade" || "$deployment_status" == "pending-install" ]]; then
|
2019-03-27 05:36:01 -04:00
|
|
|
status=0;
|
|
|
|
else
|
|
|
|
status=1;
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echoerr "Previous deployment NOT found."
|
|
|
|
fi
|
|
|
|
return $status
|
|
|
|
}
|
|
|
|
|
2019-08-27 07:01:13 -04:00
|
|
|
function delete_release() {
|
2021-06-07 08:10:00 -04:00
|
|
|
local namespace="${CI_ENVIRONMENT_SLUG}"
|
2019-11-21 13:06:26 -05:00
|
|
|
local release="${CI_ENVIRONMENT_SLUG}"
|
|
|
|
|
|
|
|
if [ -z "${release}" ]; then
|
2019-03-27 05:36:01 -04:00
|
|
|
echoerr "No release given, aborting the delete!"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2021-07-09 08:08:17 -04:00
|
|
|
if deploy_exists "${namespace}" "${release}"; then
|
|
|
|
helm uninstall --namespace="${namespace}" "${release}"
|
|
|
|
fi
|
2019-11-27 13:06:30 -05:00
|
|
|
}
|
|
|
|
|
2019-09-09 15:29:44 -04:00
|
|
|
function delete_failed_release() {
|
2021-06-07 08:10:00 -04:00
|
|
|
local namespace="${CI_ENVIRONMENT_SLUG}"
|
2019-11-21 13:06:26 -05:00
|
|
|
local release="${CI_ENVIRONMENT_SLUG}"
|
|
|
|
|
|
|
|
if [ -z "${release}" ]; then
|
2019-09-09 15:29:44 -04:00
|
|
|
echoerr "No release given, aborting the delete!"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2019-11-21 13:06:26 -05:00
|
|
|
if ! deploy_exists "${namespace}" "${release}"; then
|
|
|
|
echoinfo "No Review App with ${release} is currently deployed."
|
2019-09-09 15:29:44 -04:00
|
|
|
else
|
|
|
|
# Cleanup and previous installs, as FAILED and PENDING_UPGRADE will cause errors with `upgrade`
|
2019-11-21 13:06:26 -05:00
|
|
|
if previous_deploy_failed "${namespace}" "${release}" ; then
|
2021-06-07 08:10:00 -04:00
|
|
|
echoinfo "Review App deployment in bad state, cleaning up namespace ${release}"
|
2021-07-09 08:08:17 -04:00
|
|
|
delete_k8s_release_namespace
|
2019-09-09 15:29:44 -04:00
|
|
|
else
|
|
|
|
echoinfo "Review App deployment in good state"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-06-07 08:10:00 -04:00
|
|
|
function delete_k8s_release_namespace() {
|
|
|
|
local namespace="${CI_ENVIRONMENT_SLUG}"
|
|
|
|
|
|
|
|
kubectl delete namespace "${namespace}" --wait
|
|
|
|
}
|
|
|
|
|
2019-03-27 05:36:01 -04:00
|
|
|
function get_pod() {
|
2021-06-07 08:10:00 -04:00
|
|
|
local namespace="${CI_ENVIRONMENT_SLUG}"
|
2019-11-21 13:06:26 -05:00
|
|
|
local release="${CI_ENVIRONMENT_SLUG}"
|
2019-03-27 05:36:01 -04:00
|
|
|
local app_name="${1}"
|
|
|
|
local status="${2-Running}"
|
2019-11-21 13:06:26 -05:00
|
|
|
|
|
|
|
get_pod_cmd="kubectl get pods --namespace ${namespace} --field-selector=status.phase=${status} -lapp=${app_name},release=${release} --no-headers -o=custom-columns=NAME:.metadata.name | tail -n 1"
|
2019-05-23 10:37:29 -04:00
|
|
|
echoinfo "Waiting till '${app_name}' pod is ready" true
|
|
|
|
echoinfo "Running '${get_pod_cmd}'"
|
2019-03-27 05:36:01 -04:00
|
|
|
|
2019-05-23 10:37:29 -04:00
|
|
|
local interval=5
|
|
|
|
local elapsed_seconds=0
|
|
|
|
local max_seconds=$((2 * 60))
|
2019-03-27 05:36:01 -04:00
|
|
|
while true; do
|
2019-04-09 07:12:49 -04:00
|
|
|
local pod_name
|
|
|
|
pod_name="$(eval "${get_pod_cmd}")"
|
2019-03-27 05:36:01 -04:00
|
|
|
[[ "${pod_name}" == "" ]] || break
|
|
|
|
|
2019-05-23 10:37:29 -04:00
|
|
|
if [[ "${elapsed_seconds}" -gt "${max_seconds}" ]]; then
|
|
|
|
echoerr "The pod name couldn't be found after ${elapsed_seconds} seconds, aborting."
|
2019-06-20 04:59:31 -04:00
|
|
|
break
|
2019-05-23 10:37:29 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
let "elapsed_seconds+=interval"
|
|
|
|
sleep ${interval}
|
2019-03-27 05:36:01 -04:00
|
|
|
done
|
|
|
|
|
|
|
|
echoinfo "The pod name is '${pod_name}'."
|
|
|
|
echo "${pod_name}"
|
|
|
|
}
|
2018-11-06 17:59:25 -05:00
|
|
|
|
2020-06-30 11:08:48 -04:00
|
|
|
function run_task() {
|
2021-06-07 08:10:00 -04:00
|
|
|
local namespace="${CI_ENVIRONMENT_SLUG}"
|
2020-06-30 11:08:48 -04:00
|
|
|
local ruby_cmd="${1}"
|
|
|
|
local task_runner_pod=$(get_pod "task-runner")
|
|
|
|
|
2020-10-05 08:08:47 -04:00
|
|
|
kubectl exec --namespace "${namespace}" "${task_runner_pod}" -- gitlab-rails runner "${ruby_cmd}"
|
2020-06-30 11:08:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function disable_sign_ups() {
|
|
|
|
if [ -z ${REVIEW_APPS_ROOT_TOKEN+x} ]; then
|
|
|
|
echoerr "In order to protect Review Apps, REVIEW_APPS_ROOT_TOKEN variable must be set"
|
|
|
|
false
|
|
|
|
else
|
|
|
|
true
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Create the root token
|
2021-06-09 05:10:18 -04:00
|
|
|
local set_token_rb="token = User.find_by_username('root').personal_access_tokens.create(scopes: [:api], name: 'Token to disable sign-ups'); token.set_token('${REVIEW_APPS_ROOT_TOKEN}'); begin; token.save!; rescue(ActiveRecord::RecordNotUnique); end"
|
|
|
|
retry "run_task \"${set_token_rb}\""
|
2020-06-30 11:08:48 -04:00
|
|
|
|
|
|
|
# Disable sign-ups
|
2021-06-09 05:10:18 -04:00
|
|
|
local disable_signup_rb="Gitlab::CurrentSettings.current_application_settings.update!(signup_enabled: false)"
|
|
|
|
if (retry "run_task \"${disable_signup_rb}\""); then
|
2020-06-30 11:08:48 -04:00
|
|
|
echoinfo "Sign-ups have been disabled successfully."
|
|
|
|
else
|
2020-09-02 14:10:40 -04:00
|
|
|
echoerr "Sign-ups are still enabled!"
|
2020-06-30 11:08:48 -04:00
|
|
|
false
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-09-25 10:32:53 -04:00
|
|
|
function check_kube_domain() {
|
2019-03-27 05:36:01 -04:00
|
|
|
echoinfo "Checking that Kube domain exists..." true
|
|
|
|
|
2018-09-25 10:32:53 -04:00
|
|
|
if [ -z ${REVIEW_APPS_DOMAIN+x} ]; then
|
|
|
|
echo "In order to deploy or use Review Apps, REVIEW_APPS_DOMAIN variable must be set"
|
|
|
|
echo "You can do it in Auto DevOps project settings or defining a variable at group or project level"
|
|
|
|
echo "You can also manually add it in .gitlab-ci.yml"
|
|
|
|
false
|
|
|
|
else
|
|
|
|
true
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function ensure_namespace() {
|
2021-06-07 08:10:00 -04:00
|
|
|
local namespace="${1}"
|
2019-11-21 13:06:26 -05:00
|
|
|
|
|
|
|
echoinfo "Ensuring the ${namespace} namespace exists..." true
|
2019-03-27 05:36:01 -04:00
|
|
|
|
2019-11-21 13:06:26 -05:00
|
|
|
kubectl describe namespace "${namespace}" || kubectl create namespace "${namespace}"
|
2018-09-25 10:32:53 -04:00
|
|
|
}
|
|
|
|
|
2021-06-11 08:09:49 -04:00
|
|
|
function label_namespace() {
|
|
|
|
local namespace="${1}"
|
|
|
|
local label="${2}"
|
|
|
|
|
|
|
|
echoinfo "Labeling the ${namespace} namespace with ${label}" true
|
2021-06-22 05:07:12 -04:00
|
|
|
echoinfo "We should pass the --overwrite option!"
|
2021-06-11 08:09:49 -04:00
|
|
|
|
2021-06-22 05:07:12 -04:00
|
|
|
kubectl label --overwrite namespace "${namespace}" "${label}"
|
2021-06-11 08:09:49 -04:00
|
|
|
}
|
|
|
|
|
2019-05-23 10:37:29 -04:00
|
|
|
function create_application_secret() {
|
2021-06-07 08:10:00 -04:00
|
|
|
local namespace="${CI_ENVIRONMENT_SLUG}"
|
2019-11-21 13:06:26 -05:00
|
|
|
local release="${CI_ENVIRONMENT_SLUG}"
|
2019-11-27 07:06:30 -05:00
|
|
|
local initial_root_password_shared_secret
|
|
|
|
local gitlab_license_shared_secret
|
|
|
|
|
|
|
|
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)
|
|
|
|
if [[ "${initial_root_password_shared_secret}" == "" ]]; then
|
|
|
|
echoinfo "Creating the 'shared-gitlab-initial-root-password' secret in the ${namespace} namespace..." true
|
|
|
|
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
|
2019-11-04 13:06:28 -05:00
|
|
|
|
2021-05-17 08:10:23 -04:00
|
|
|
if [ -z "${REVIEW_APPS_EE_LICENSE_FILE}" ]; then echo "License not found" && return; fi
|
2019-11-04 13:06:28 -05:00
|
|
|
|
2019-11-27 07:06:30 -05:00
|
|
|
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
|
|
|
|
echoinfo "Creating the 'shared-gitlab-license' secret in the ${namespace} namespace..." true
|
|
|
|
kubectl create secret generic --namespace "${namespace}" \
|
|
|
|
"shared-gitlab-license" \
|
2021-05-17 08:10:23 -04:00
|
|
|
--from-file=license="${REVIEW_APPS_EE_LICENSE_FILE}" \
|
2019-11-27 07:06:30 -05:00
|
|
|
--dry-run -o json | kubectl apply -f -
|
|
|
|
else
|
|
|
|
echoinfo "The 'shared-gitlab-license' secret already exists in the ${namespace} namespace."
|
|
|
|
fi
|
2019-11-25 07:06:13 -05:00
|
|
|
}
|
|
|
|
|
2019-05-23 10:37:29 -04:00
|
|
|
function download_chart() {
|
2019-03-27 05:36:01 -04:00
|
|
|
echoinfo "Downloading the GitLab chart..." true
|
2018-09-20 10:37:21 -04:00
|
|
|
|
2019-09-03 11:04:00 -04:00
|
|
|
curl --location -o gitlab.tar.bz2 "https://gitlab.com/gitlab-org/charts/gitlab/-/archive/${GITLAB_HELM_CHART_REF}/gitlab-${GITLAB_HELM_CHART_REF}.tar.bz2"
|
2019-03-27 05:36:01 -04:00
|
|
|
tar -xjf gitlab.tar.bz2
|
|
|
|
|
|
|
|
echoinfo "Adding the gitlab repo to Helm..."
|
|
|
|
helm repo add gitlab https://charts.gitlab.io
|
|
|
|
|
|
|
|
echoinfo "Building the gitlab chart's dependencies..."
|
2021-04-29 02:09:58 -04:00
|
|
|
helm dependency build "gitlab-${GITLAB_HELM_CHART_REF}"
|
2018-09-25 10:32:53 -04:00
|
|
|
}
|
|
|
|
|
2019-10-30 11:14:17 -04:00
|
|
|
function base_config_changed() {
|
2019-11-08 07:06:32 -05:00
|
|
|
if [ -z "${CI_MERGE_REQUEST_IID}" ]; then return; fi
|
2019-10-30 11:14:17 -04:00
|
|
|
|
2019-11-08 07:06:32 -05:00
|
|
|
curl "${CI_API_V4_URL}/projects/${CI_MERGE_REQUEST_PROJECT_ID}/merge_requests/${CI_MERGE_REQUEST_IID}/changes" | jq '.changes | any(.old_path == "scripts/review_apps/base-config.yaml")'
|
2019-10-30 11:14:17 -04:00
|
|
|
}
|
|
|
|
|
2020-07-15 14:09:09 -04:00
|
|
|
function parse_gitaly_image_tag() {
|
|
|
|
local gitaly_version="${GITALY_VERSION}"
|
|
|
|
|
2020-07-16 08:09:22 -04:00
|
|
|
# prepend semver version with `v`
|
|
|
|
if [[ $gitaly_version =~ ^[0-9]+\.[0-9]+\.[0-9]+(-rc[0-9]+)?(-ee)?$ ]]; then
|
2020-07-15 14:09:09 -04:00
|
|
|
echo "v${gitaly_version}"
|
2020-07-16 08:09:22 -04:00
|
|
|
else
|
|
|
|
echo "${gitaly_version}"
|
2020-07-15 14:09:09 -04:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-09-25 10:32:53 -04:00
|
|
|
function deploy() {
|
2021-06-07 08:10:00 -04:00
|
|
|
local namespace="${CI_ENVIRONMENT_SLUG}"
|
2019-11-21 13:06:26 -05:00
|
|
|
local release="${CI_ENVIRONMENT_SLUG}"
|
2021-04-21 14:11:09 -04:00
|
|
|
local base_config_file_ref="${CI_DEFAULT_BRANCH}"
|
2019-11-21 13:06:26 -05:00
|
|
|
if [[ "$(base_config_changed)" == "true" ]]; then base_config_file_ref="${CI_COMMIT_SHA}"; fi
|
2019-10-30 11:14:17 -04:00
|
|
|
local base_config_file="https://gitlab.com/gitlab-org/gitlab/raw/${base_config_file_ref}/scripts/review_apps/base-config.yaml"
|
|
|
|
|
2021-03-03 07:11:16 -05:00
|
|
|
echoinfo "Deploying ${release} to ${CI_ENVIRONMENT_URL} ..." true
|
2018-09-25 10:32:53 -04:00
|
|
|
|
2018-11-06 17:59:25 -05:00
|
|
|
IMAGE_REPOSITORY="registry.gitlab.com/gitlab-org/build/cng-mirror"
|
2020-05-05 08:09:31 -04:00
|
|
|
gitlab_migrations_image_repository="${IMAGE_REPOSITORY}/gitlab-rails-ee"
|
|
|
|
gitlab_sidekiq_image_repository="${IMAGE_REPOSITORY}/gitlab-sidekiq-ee"
|
2020-06-10 05:08:35 -04:00
|
|
|
gitlab_webservice_image_repository="${IMAGE_REPOSITORY}/gitlab-webservice-ee"
|
2020-05-05 08:09:31 -04:00
|
|
|
gitlab_task_runner_image_repository="${IMAGE_REPOSITORY}/gitlab-task-runner-ee"
|
2018-11-06 17:59:25 -05:00
|
|
|
gitlab_gitaly_image_repository="${IMAGE_REPOSITORY}/gitaly"
|
2020-07-15 14:09:09 -04:00
|
|
|
gitaly_image_tag=$(parse_gitaly_image_tag)
|
2018-11-06 17:59:25 -05:00
|
|
|
gitlab_shell_image_repository="${IMAGE_REPOSITORY}/gitlab-shell"
|
2020-05-05 08:09:31 -04:00
|
|
|
gitlab_workhorse_image_repository="${IMAGE_REPOSITORY}/gitlab-workhorse-ee"
|
2018-09-25 10:32:53 -04:00
|
|
|
|
2021-06-07 08:10:00 -04:00
|
|
|
ensure_namespace "${namespace}"
|
2021-06-11 08:09:49 -04:00
|
|
|
label_namespace "${namespace}" "tls=review-apps-tls" # label namespace for kubed to sync tls
|
2021-06-07 08:10:00 -04:00
|
|
|
|
2019-05-23 10:37:29 -04:00
|
|
|
create_application_secret
|
2018-09-25 10:32:53 -04:00
|
|
|
|
|
|
|
HELM_CMD=$(cat << EOF
|
2019-11-21 13:06:26 -05:00
|
|
|
helm upgrade \
|
|
|
|
--namespace="${namespace}" \
|
2021-06-07 08:10:00 -04:00
|
|
|
--create-namespace \
|
2019-11-21 13:06:26 -05:00
|
|
|
--install \
|
2019-08-27 07:01:13 -04:00
|
|
|
--wait \
|
2021-05-18 05:10:37 -04:00
|
|
|
--timeout "${HELM_INSTALL_TIMEOUT:-20m}" \
|
2019-11-21 13:06:26 -05:00
|
|
|
--set ci.branch="${CI_COMMIT_REF_NAME}" \
|
|
|
|
--set ci.commit.sha="${CI_COMMIT_SHORT_SHA}" \
|
|
|
|
--set ci.job.url="${CI_JOB_URL}" \
|
|
|
|
--set ci.pipeline.url="${CI_PIPELINE_URL}" \
|
|
|
|
--set releaseOverride="${release}" \
|
|
|
|
--set global.hosts.hostSuffix="${HOST_SUFFIX}" \
|
|
|
|
--set global.hosts.domain="${REVIEW_APPS_DOMAIN}" \
|
|
|
|
--set gitlab.migrations.image.repository="${gitlab_migrations_image_repository}" \
|
|
|
|
--set gitlab.migrations.image.tag="${CI_COMMIT_REF_SLUG}" \
|
|
|
|
--set gitlab.gitaly.image.repository="${gitlab_gitaly_image_repository}" \
|
2020-07-15 14:09:09 -04:00
|
|
|
--set gitlab.gitaly.image.tag="${gitaly_image_tag}" \
|
2019-11-21 13:06:26 -05:00
|
|
|
--set gitlab.gitlab-shell.image.repository="${gitlab_shell_image_repository}" \
|
|
|
|
--set gitlab.gitlab-shell.image.tag="v${GITLAB_SHELL_VERSION}" \
|
2020-05-11 08:10:28 -04:00
|
|
|
--set gitlab.sidekiq.annotations.commit="${CI_COMMIT_SHORT_SHA}" \
|
2019-11-21 13:06:26 -05:00
|
|
|
--set gitlab.sidekiq.image.repository="${gitlab_sidekiq_image_repository}" \
|
|
|
|
--set gitlab.sidekiq.image.tag="${CI_COMMIT_REF_SLUG}" \
|
2020-06-10 05:08:35 -04:00
|
|
|
--set gitlab.webservice.annotations.commit="${CI_COMMIT_SHORT_SHA}" \
|
|
|
|
--set gitlab.webservice.image.repository="${gitlab_webservice_image_repository}" \
|
|
|
|
--set gitlab.webservice.image.tag="${CI_COMMIT_REF_SLUG}" \
|
|
|
|
--set gitlab.webservice.workhorse.image="${gitlab_workhorse_image_repository}" \
|
|
|
|
--set gitlab.webservice.workhorse.tag="${CI_COMMIT_REF_SLUG}" \
|
2019-11-21 13:06:26 -05:00
|
|
|
--set gitlab.task-runner.image.repository="${gitlab_task_runner_image_repository}" \
|
|
|
|
--set gitlab.task-runner.image.tag="${CI_COMMIT_REF_SLUG}"
|
2019-06-28 05:38:38 -04:00
|
|
|
EOF
|
|
|
|
)
|
|
|
|
|
2021-05-17 08:10:23 -04:00
|
|
|
if [ -n "${REVIEW_APPS_EE_LICENSE_FILE}" ]; then
|
2019-11-04 13:06:28 -05:00
|
|
|
HELM_CMD=$(cat << EOF
|
|
|
|
${HELM_CMD} \
|
2019-11-27 07:06:30 -05:00
|
|
|
--set global.gitlab.license.secret="shared-gitlab-license"
|
2019-11-04 13:06:28 -05:00
|
|
|
EOF
|
|
|
|
)
|
|
|
|
fi
|
|
|
|
|
2019-06-28 05:38:38 -04:00
|
|
|
HELM_CMD=$(cat << EOF
|
2019-10-30 11:14:17 -04:00
|
|
|
${HELM_CMD} \
|
|
|
|
--version="${CI_PIPELINE_ID}-${CI_JOB_ID}" \
|
|
|
|
-f "${base_config_file}" \
|
2021-05-19 20:10:36 -04:00
|
|
|
-v "${HELM_LOG_VERBOSITY:-1}" \
|
2021-04-29 02:09:58 -04:00
|
|
|
"${release}" "gitlab-${GITLAB_HELM_CHART_REF}"
|
2018-09-25 10:32:53 -04:00
|
|
|
EOF
|
|
|
|
)
|
|
|
|
|
2019-03-27 05:36:01 -04:00
|
|
|
echoinfo "Deploying with:"
|
|
|
|
echoinfo "${HELM_CMD}"
|
2018-09-25 10:32:53 -04:00
|
|
|
|
2019-05-23 10:37:29 -04:00
|
|
|
eval "${HELM_CMD}"
|
|
|
|
}
|
|
|
|
|
2021-06-09 05:10:18 -04:00
|
|
|
function verify_deploy() {
|
|
|
|
echoinfo "Verifying deployment at ${CI_ENVIRONMENT_URL}"
|
|
|
|
|
2021-06-10 05:10:04 -04:00
|
|
|
if retry "test_url \"${CI_ENVIRONMENT_URL}\" curl_output.txt"; then
|
2021-06-09 05:10:18 -04:00
|
|
|
echoinfo "Review app is deployed to ${CI_ENVIRONMENT_URL}"
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
echoerr "Review app is not available at ${CI_ENVIRONMENT_URL}. See curl_output.txt artifact for detail."
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-05-23 10:37:29 -04:00
|
|
|
function display_deployment_debug() {
|
2021-06-07 08:10:00 -04:00
|
|
|
local namespace="${CI_ENVIRONMENT_SLUG}"
|
2019-11-21 13:06:26 -05:00
|
|
|
local release="${CI_ENVIRONMENT_SLUG}"
|
|
|
|
|
2019-10-10 11:06:07 -04:00
|
|
|
# Get all pods for this release
|
2019-11-21 13:06:26 -05:00
|
|
|
echoinfo "Pods for release ${release}"
|
|
|
|
kubectl get pods --namespace "${namespace}" -lrelease=${release}
|
2019-09-13 09:26:31 -04:00
|
|
|
|
2019-10-07 08:06:18 -04:00
|
|
|
# Get all non-completed jobs
|
2019-11-21 13:06:26 -05:00
|
|
|
echoinfo "Unsuccessful Jobs for release ${release}"
|
|
|
|
kubectl get jobs --namespace "${namespace}" -lrelease=${release} --field-selector=status.successful!=1
|
2019-04-08 13:10:18 -04:00
|
|
|
}
|