Newer
Older
stages:
- deploy_ocf_staging
- delete_ocf_staging
- deploy_ocf_dev
- delete_ocf_dev
variables:
NAMESPACE_DEV: "ocf-dev-$CI_ENVIRONMENT_SLUG"
NAMESPACE_STAGING: "ocf-staging"
DOMAIN_STAGING: staging.int
DOMAIN_DEV: developer.int
DOMAIN_PROD: prod.int
IMAGE_TAG_DEV: $CI_COMMIT_REF_SLUG
IMAGE_TAG_STAGING: $CI_COMMIT_REF_SLUG
VAULT_HOSTNAME: $VAULT_HOSTNAME
VAULT_PORT: $VAULT_PORT
VAULT_ACCESS_TOKEN: $VAULT_ACCESS_TOKEN
.main_common: &main_common
only:
- merge_requests
except:
variables:
# - $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != "main"
- $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != "staging"
.staging_common: &staging_common
only:
- merge_requests
except:
variables:
- $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != "staging"
tags:
- shell
.dev_common: &dev_common
tags:
- shell
deploy_ocf_staging:
stage: deploy_ocf_staging
<<: *staging_common
environment:
name: review/staging
url: https://capif-$CI_ENVIRONMENT_SLUG.$DOMAIN_STAGING
# rules:
# - if: $CI_COMMIT_BRANCH == "main"
# when: never
# - if: $CI_COMMIT_BRANCH == "staging"
# - echo "### git clone OCF repo ###"
# - git clone https://oauth2:${CI_JOB_TOKEN}@labs.etsi.org/rep/ocf/capif.git
# - echo "### install helm###"
# - curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
# - chmod 700 get_helm.sh
# - sudo ./get_helm.sh
- helm version
- kubectl version --output=yaml
- echo "### setting kubeconfig###"
- yq e -i ".appVersion = \"$IMAGE_TAG_STAGING\"" helm/capif/Chart.yaml
- cat helm/capif/Chart.yaml
- echo "### download dependencies###"
- helm dependency build helm/capif
- echo "### updating capif###"
# - helm uninstall -n $NAMESPACE_STAGING ocf-staging || true
# - helm upgrade --install -n $NAMESPACE_STAGING ocf-staging helm/capif/ \
# --set nginx.nginx.env.capifHostname=capif-$CI_ENVIRONMENT_SLUG.$DOMAIN_STAGING \
# --set nginx.nginx.env.registerHostname=register-$CI_ENVIRONMENT_SLUG.$DOMAIN_STAGING \
# --set monitoring.grafana.ingress.hosts[0].host="grafana-$CI_ENVIRONMENT_SLUG.$DOMAIN_STAGING" \
# --set monitoring.grafana.ingress.hosts[0].paths[0].path="/" \
# --set monitoring.grafana.ingress.hosts[0].paths[0].pathType="Prefix" \
# --set monitoring.grafana.env.prometheusURL=http://prometheus.ocf.pre-production \
# --set tempo.tempo.metricsGenerator.remoteWriteUrl=http://prometheus.ocf.pre-production/api/v1/write \
# --set parametersVault.env.vaultHostname=$VAULT_HOSTNAME \
# --set parametersVault.env.vaultPort=$VAULT_PORT \
# --set parametersVault.env.vaultAccessToken=$VAULT_ACCESS_TOKEN \
# --set ingress.ip=10.43.107.132 \
# --wait --timeout=10m \
# --create-namespace --atomic
delete_ocf_staging:
stage: delete_ocf_staging
<<: *staging_common
script:
- echo "### deleting environment $NAMESPACE_STAGING###"
# - helm uninstall -n $NAMESPACE_STAGING ocf-staging
when: manual
environment:
name: review/staging
action: stop
## dev ###
deploy_ocf_dev:
stage: deploy_ocf_dev
<<: *dev_common
environment:
name: review/$CI_COMMIT_REF_SLUG
url: https://capif-$CI_ENVIRONMENT_SLUG.$DOMAIN_DEV
# rules:
# - if: $CI_COMMIT_BRANCH == "main"
# when: never
# - if: $CI_COMMIT_BRANCH == "staging"
# when: never
# - if: $CI_COMMIT_BRANCH
- helm version
- kubectl version --output=yaml
- echo "### setting kubeconfig###"
- yq e -i ".appVersion = \"$IMAGE_TAG_DEV\"" helm/capif/Chart.yaml
- cat helm/capif/Chart.yaml
- echo "### download dependencies###"
- helm dependency build helm/capif
- echo "### updating capif###"
- helm uninstall -n $NAMESPACE_DEV ocf-developer || true
- helm upgrade --install -n $NAMESPACE_DEV ocf-developer helm/capif/ --set nginx.nginx.env.capifHostname=capif-$CI_ENVIRONMENT_SLUG.$DOMAIN_DEV --set nginx.nginx.env.registerHostname=register-$CI_ENVIRONMENT_SLUG.$DOMAIN_DEV \
--set monitoring.grafana.ingress.hosts[0].host="grafana-$CI_ENVIRONMENT_SLUG.$DOMAIN_PROD" \
--set monitoring.grafana.ingress.hosts[0].paths[0].path="/" \
--set monitoring.grafana.ingress.hosts[0].paths[0].pathType="Prefix" \
--set monitoring.grafana.env.prometheusURL=http://prometheus.ocf.pre-production \
--set tempo.tempo.metricsGenerator.remoteWriteUrl=http://prometheus.ocf.pre-production/api/v1/write \
--set parametersVault.env.vaultHostname=$VAULT_HOSTNAME \
--set parametersVault.env.vaultPort=$VAULT_PORT \
--set parametersVault.env.vaultAccessToken=$VAULT_ACCESS_TOKEN \
--set ingress.ip=10.43.107.132 \
--wait --timeout=10m \
delete_ocf_dev:
stage: delete_ocf_dev
<<: *staging_common
script:
- echo "### deleting environment $NAMESPACE_DEV###"
when: manual
environment:
name: review/$CI_COMMIT_REF_SLUG
action: stop