Skip to content

Commit

Permalink
CI: Move deployment to argocd (#574)
Browse files Browse the repository at this point in the history
  • Loading branch information
BulatSaif authored Feb 8, 2024
1 parent 6635087 commit 338f813
Showing 1 changed file with 21 additions and 49 deletions.
70 changes: 21 additions & 49 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@ variables:
CONTAINER_REPO: ""
DOCKERFILE_DIRECTORY: ""

# Deploy Variables (Mandatory)
HELM_NAMESPACE: "substrate-telemetry"
HELM_RELEASE_NAME: "substrate-telemetry"
HELM_CHART: "parity/substrate-telemetry"

# Deploy Variables (Optional)
HELM_REPO_NAME: "parity"
HELM_REPO_URL: "https://paritytech.github.io/helm-charts/"
HELM_CONFIGMAP_NAME: "helm-custom-values"
HELM_CONFIGMAP_KEYNAME: "values-parity.yaml"

# Manual Variables (Optional)
## Could be used in the webconsole when triggering the pipeline manually
Expand Down Expand Up @@ -114,37 +104,22 @@ stages:
- kubernetes-parity-build

.deploy: &deploy
image: paritytech/kubetools:3.5.3
image: quay.io/argoproj/argocd:v2.7.9
variables:
ARGOCD_OPTS: --grpc-web --grpc-web-root-path /$ENVIRONMENT
APP: substrate-telemetry
environment:
name: $ENVIRONMENT
script:
- |-
echo generating an empty custom-values.yaml file
touch custom-values.yaml
- |-
echo fetching the custom values file from the configmap if HELM_CONFIGMAP_NAME is specified
if [[ $HELM_CONFIGMAP_NAME ]]; then
# escape dot characters
HELM_CONFIGMAP_KEYNAME=`echo $HELM_CONFIGMAP_KEYNAME | sed 's/\./\\\./g'`
kubectl get cm $HELM_CONFIGMAP_NAME -n $HELM_NAMESPACE -o jsonpath="{.data.$HELM_CONFIGMAP_KEYNAME}" \
> custom-values.yaml
fi
- |-
echo adding the helm repository if HELM_REPO_URL is specified
if [[ $HELM_REPO_URL ]]; then
helm repo add $HELM_REPO_NAME $HELM_REPO_URL
helm repo update
fi
- echo installing the helm chart
- helm upgrade
--install
--atomic
--timeout 300s
--namespace $HELM_NAMESPACE
--values custom-values.yaml
--set image.backend.repository="${CONTAINER_REPO_BACKEND}"
--set image.backend.tag="${DOCKER_IMAGE_TAG}"
--set image.frontend.repository="${CONTAINER_REPO_FRONTEND}"
--set image.frontend.tag="${DOCKER_IMAGE_TAG}"
${HELM_RELEASE_NAME} ${HELM_CHART}
- argocd app list
- argocd app set $APP
--helm-set substrate-telemetry.image.backend.repository="${CONTAINER_REPO_BACKEND}"
--helm-set substrate-telemetry.image.backend.tag="${DOCKER_IMAGE_TAG}"
--helm-set substrate-telemetry.image.frontend.repository="${CONTAINER_REPO_FRONTEND}"
--helm-set substrate-telemetry.image.frontend.tag="${DOCKER_IMAGE_TAG}"
- argocd app sync $APP
# uncomment after https://github.com/paritytech/devops/issues/3141 is done
# - argocd app wait $APP --timeout 180
tags:
- kubernetes-parity-build

Expand Down Expand Up @@ -205,10 +180,9 @@ deploy-commit-to-staging:
variables:
CONTAINER_REPO_BACKEND: "docker.io/paritypr/substrate-telemetry-backend"
CONTAINER_REPO_FRONTEND: "docker.io/paritypr/substrate-telemetry-frontend"
ENVIRONMENT: "parity-stg"
stage: deploy-commit-to-staging
<<: *deploy
environment:
name: parity-stg
extends: .deploy
rules:
- if: '$CI_COMMIT_BRANCH =~ /^[0-9]+/'
when: manual
Expand All @@ -218,10 +192,9 @@ deploy-master-to-staging:
variables:
CONTAINER_REPO_BACKEND: "docker.io/parity/substrate-telemetry-backend"
CONTAINER_REPO_FRONTEND: "docker.io/parity/substrate-telemetry-frontend"
ENVIRONMENT: "parity-stg"
stage: deploy-master-to-staging
<<: *deploy
environment:
name: parity-stg
extends: .deploy
rules:
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+.*$/' # i.e. v1.0, v2.1rc1
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
Expand All @@ -231,10 +204,9 @@ deploy-production:
variables:
CONTAINER_REPO_BACKEND: "docker.io/parity/substrate-telemetry-backend"
CONTAINER_REPO_FRONTEND: "docker.io/parity/substrate-telemetry-frontend"
ENVIRONMENT: "parity-prod"
stage: deploy-production
<<: *deploy
environment:
name: parity-prod
extends: .deploy
rules:
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+.*$/' # i.e. v1.0, v2.1rc1
when: manual
Expand Down

0 comments on commit 338f813

Please sign in to comment.