Commit 6fe15fdc authored by Mayra Cabrera's avatar Mayra Cabrera

Modifies ADO script to include new variable

Ensure KUBE_INGRESS_BASE_DOMAIN existence by setting his value to
AUTO_DEVOPS_DOMAIN if the first one doesnt exists. Also made
corresponding changes throughout the whole script

Related to !24580
parent 8ff73614
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
# #
# In order to deploy, you must have a Kubernetes cluster configured either # In order to deploy, you must have a Kubernetes cluster configured either
# via a project integration, or via group/project variables. # via a project integration, or via group/project variables.
# AUTO_DEVOPS_DOMAIN must also be set as a variable at the group or project # KUBE_INGRESS_BASE_DOMAIN must also be set on the cluster settings,
# level, or manually added below. # as a variable at the group or project level, or manually added below.
# #
# Continuous deployment to production is enabled by default. # Continuous deployment to production is enabled by default.
# If you want to deploy to staging first, set STAGING_ENABLED environment variable. # If you want to deploy to staging first, set STAGING_ENABLED environment variable.
...@@ -41,8 +41,8 @@ ...@@ -41,8 +41,8 @@
image: alpine:latest image: alpine:latest
variables: variables:
# AUTO_DEVOPS_DOMAIN is the application deployment domain and should be set as a variable at the group or project level. # KUBE_INGRESS_BASE_DOMAIN is the application deployment domain and should be set as a variable at the group or project level.
# AUTO_DEVOPS_DOMAIN: domain.example.com # KUBE_INGRESS_BASE_DOMAIN: domain.example.com
POSTGRES_USER: user POSTGRES_USER: user
POSTGRES_PASSWORD: testing-password POSTGRES_PASSWORD: testing-password
...@@ -251,7 +251,7 @@ review: ...@@ -251,7 +251,7 @@ review:
- persist_environment_url - persist_environment_url
environment: environment:
name: review/$CI_COMMIT_REF_NAME name: review/$CI_COMMIT_REF_NAME
url: http://$CI_PROJECT_PATH_SLUG-$CI_ENVIRONMENT_SLUG.$AUTO_DEVOPS_DOMAIN url: http://$CI_PROJECT_PATH_SLUG-$CI_ENVIRONMENT_SLUG.$KUBE_INGRESS_BASE_DOMAIN
on_stop: stop_review on_stop: stop_review
artifacts: artifacts:
paths: [environment_url.txt] paths: [environment_url.txt]
...@@ -306,7 +306,7 @@ staging: ...@@ -306,7 +306,7 @@ staging:
- deploy - deploy
environment: environment:
name: staging name: staging
url: http://$CI_PROJECT_PATH_SLUG-staging.$AUTO_DEVOPS_DOMAIN url: http://$CI_PROJECT_PATH_SLUG-staging.$KUBE_INGRESS_BASE_DOMAIN
only: only:
refs: refs:
- master - master
...@@ -330,7 +330,7 @@ canary: ...@@ -330,7 +330,7 @@ canary:
- deploy canary - deploy canary
environment: environment:
name: production name: production
url: http://$CI_PROJECT_PATH_SLUG.$AUTO_DEVOPS_DOMAIN url: http://$CI_PROJECT_PATH_SLUG.$KUBE_INGRESS_BASE_DOMAIN
when: manual when: manual
only: only:
refs: refs:
...@@ -354,7 +354,7 @@ canary: ...@@ -354,7 +354,7 @@ canary:
- persist_environment_url - persist_environment_url
environment: environment:
name: production name: production
url: http://$CI_PROJECT_PATH_SLUG.$AUTO_DEVOPS_DOMAIN url: http://$CI_PROJECT_PATH_SLUG.$KUBE_INGRESS_BASE_DOMAIN
artifacts: artifacts:
paths: [environment_url.txt] paths: [environment_url.txt]
...@@ -403,7 +403,7 @@ production_manual: ...@@ -403,7 +403,7 @@ production_manual:
- persist_environment_url - persist_environment_url
environment: environment:
name: production name: production
url: http://$CI_PROJECT_PATH_SLUG.$AUTO_DEVOPS_DOMAIN url: http://$CI_PROJECT_PATH_SLUG.$KUBE_INGRESS_BASE_DOMAIN
artifacts: artifacts:
paths: [environment_url.txt] paths: [environment_url.txt]
...@@ -823,11 +823,24 @@ rollout 100%: ...@@ -823,11 +823,24 @@ rollout 100%:
kubectl describe namespace "$KUBE_NAMESPACE" || kubectl create namespace "$KUBE_NAMESPACE" kubectl describe namespace "$KUBE_NAMESPACE" || kubectl create namespace "$KUBE_NAMESPACE"
} }
# Function to ensure backwards compatibility with AUTO_DEVOPS_DOMAIN
function ensure_kube_ingress_base_domain() {
if [ -z ${KUBE_INGRESS_BASE_DOMAIN+x} ]; then
export KUBE_INGRESS_BASE_DOMAIN=$AUTO_DEVOPS_DOMAIN
fi
}
function check_kube_domain() { function check_kube_domain() {
if [ -z ${AUTO_DEVOPS_DOMAIN+x} ]; then ensure_kube_ingress_base_domain
echo "In order to deploy or use Review Apps, AUTO_DEVOPS_DOMAIN variable must be set"
echo "You can do it in Auto DevOps project settings or defining a variable at group or project level" if [ -z ${KUBE_INGRESS_BASE_DOMAIN+x} ]; then
echo "In order to deploy or use Review Apps,"
echo "AUTO_DEVOPS_DOMAIN or KUBE_INGRESS_BASE_DOMAIN variables must be set"
echo "From 11.8, you can set KUBE_INGRESS_BASE_DOMAIN in cluster settings"
echo "or by defining a variable at group or project level."
echo "You can also manually add it in .gitlab-ci.yml" echo "You can also manually add it in .gitlab-ci.yml"
echo "AUTO_DEVOPS_DOMAIN support will be dropped on 12.0"
false false
else else
true true
......
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