Commit 4ca377b3 authored by Bryan  BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

split deploy steps in re-usable steps for dev and prod

parent d9753422
......@@ -64,12 +64,22 @@ build:
deploy_prod:
.deploy_step:
image: harbor.pasteur.fr/kube-system/helm-kubectl:3.4.0
before_script:
- helm repo add bitnami https://charts.bitnami.com/bitnami
- helm repo update
- pwd && ls -lah
- echo $NAMESPACE
- echo $CI_COMMIT_REF_SLUG
- echo $STORAGE_SUFFIX
- kubectl get pods -n $NAMESPACE
- apk add --no-cache gettext
.prod_settings:
only:
- master
stage: deploy
needs: ["build"]
image: harbor.pasteur.fr/kube-system/helm-kubectl:3.4.0
variables:
CI_DEBUG_TRACE: "false"
NAMESPACE: "viralhostrange-prod"
......@@ -81,15 +91,11 @@ deploy_prod:
environment:
name: "k8sprod-02/viralhostrange-prod/$CI_COMMIT_REF_SLUG"
url: "https://viralhostrangedb.pasteur.cloud"
.deploy_db:
script:
- helm repo add bitnami https://charts.bitnami.com/bitnami
- helm repo update
- pwd && ls -lah
- echo $NAMESPACE
- echo $CI_COMMIT_REF_SLUG
- echo $STORAGE_SUFFIX
- kubectl get pods -n $NAMESPACE
- apk add --no-cache gettext
- kubectl delete secret registry-gitlab -n $NAMESPACE --ignore-not-found=true
- kubectl create secret docker-registry -n $NAMESPACE registry-gitlab --docker-server=$CI_REGISTRY --docker-username=$DEPLOY_USER --docker-password=$DEPLOY_TOKEN --docker-email=$GITLAB_USER_EMAIL
- envsubst < k8s/config-map.yaml | kubectl apply -n $NAMESPACE -f -
......@@ -107,6 +113,11 @@ deploy_prod:
--set primary.podLabels.branch=branch${STORAGE_SUFFIX}
--set primary.podLabels.app=postgres-app
--set fullnameOverride="db${STORAGE_SUFFIX}"
.deploy_web:
script:
- envsubst < k8s/kubernetes-storage.yaml | kubectl apply -n $NAMESPACE -f -
- envsubst < k8s/manifest.yaml | kubectl apply -n $NAMESPACE -f -
# - envsubst < k8s/manifest-webhost-autoscale.yaml | kubectl apply -n $NAMESPACE -f -
......@@ -114,6 +125,26 @@ deploy_prod:
deploy_prod_db:
needs: ["build"]
stage: deploy
extends:
- .deploy_step
- .prod_settings
- .deploy_db
deploy_prod_web:
needs: ["build", "deploy_prod_db"]
stage: deploy
extends:
- .deploy_step
- .prod_settings
- .deploy_web
dump_prod_for_dev:
except:
- master
......@@ -136,10 +167,9 @@ dump_prod_for_dev:
.deploy_dev:
.dev_settings:
except:
- master
stage: deploy
image: harbor.pasteur.fr/kube-system/helm-kubectl:3.4.0
variables:
CI_DEBUG_TRACE: "false"
......@@ -157,47 +187,24 @@ dump_prod_for_dev:
deploy_dev_db:
extends: .deploy_dev
needs: ["build", "dump_prod_for_dev"]
script:
- helm repo add bitnami https://charts.bitnami.com/bitnami
- helm repo update
- pwd && ls -lah
- echo $NAMESPACE
- echo $CI_COMMIT_REF_SLUG
- echo $STORAGE_SUFFIX
- kubectl get pods -n $NAMESPACE
- apk add --no-cache gettext
- kubectl delete secret registry-gitlab -n $NAMESPACE --ignore-not-found=true
- kubectl create secret docker-registry -n $NAMESPACE registry-gitlab --docker-server=$CI_REGISTRY --docker-username=$DEPLOY_USER --docker-password=$DEPLOY_TOKEN --docker-email=$GITLAB_USER_EMAIL
- envsubst < k8s/config-map.yaml | kubectl apply -n $NAMESPACE -f -
- >
helm upgrade --install db${STORAGE_SUFFIX} bitnami/postgresql --version $CHART_VERSION --namespace=$NAMESPACE
--set image.tag=$POSTGRESQL_VERSION
--set persistence.storageClass='isilon'
--set persistence.enabled=true
--set persistence.size="5Gi"
--set image.pullPolicy='Always'
--set postgresqlUsername='postgres'
--set postgresqlPostgresPassword="$POSTGRES_PASSWORD"
--set postgresqlPassword="$POSTGRES_PASSWORD"
--set postgresqlDatabase='viralhostrangedb'
--set primary.podLabels.branch=branch${STORAGE_SUFFIX}
--set primary.podLabels.app=postgres-app
--set fullnameOverride="db${STORAGE_SUFFIX}"
stage: deploy
extends:
- .deploy_step
- .dev_settings
- .deploy_db
after_script:
- . ./k8s/init_db_from_prod.sh
deploy_dev_web:
extends: .deploy_dev
needs: ["deploy_dev_db", ]
script:
- envsubst < k8s/kubernetes-storage.yaml | kubectl apply -n $NAMESPACE -f -
- envsubst < k8s/manifest.yaml | kubectl apply -n $NAMESPACE -f -
# - envsubst < k8s/manifest-webhost-autoscale.yaml | kubectl apply -n $NAMESPACE -f -
- envsubst < k8s/kubernetes-cronjob.yaml | kubectl apply -n $NAMESPACE -f -
needs: ["build", "deploy_dev_db"]
stage: deploy
extends:
- .deploy_step
- .dev_settings
- .deploy_web
stop_and_delete_in_dev:
......
Supports Markdown
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