Deploy from CI/CD
Deploy from GitLab CI
Prerequisites: a running Workload, its service instance id, the deploy token, and zaroz-deploy.sh committed as deploy/zaroz-deploy.sh.
Variables
In Settings > CI/CD > Variables:
| Key | Settings |
|---|---|
ZAROZ_TOKEN | the zaroz_... token. Masked and Protected, so only pipelines on protected branches (main) can read it |
ZAROZ_SERVICE | the service instance UUID |
CI_DEPLOY_USER, CI_DEPLOY_PASSWORD | only for a private image. Create a deploy token with only read_registry (Settings > Repository > Deploy tokens) and GitLab fills these two variables for jobs automatically when its name is gitlab+deploy-token |
The pipeline
Code
How it behaves:
resource_group: productionmakes GitLab run one deploy job at a time and keep them in order, so an older commit never lands on top of a newer one.needs: [build]starts the deploy the moment the image is pushed.- The deploy job fails when the rollout fails, after putting the previous image back. The
environment: productionentry gives you a deployment history in GitLab beside Zaroz's. - Add
when: manualto the deploy job'srulesfor a push-button production deploy.
Roll back
In Deploy > Environments > production, press the rollback button on an older deployment: GitLab re-runs that commit's deploy job, which deploys that commit's image. By hand: IMAGE=$CI_REGISTRY_IMAGE:<old sha> sh deploy/zaroz-deploy.sh.
Self-managed GitLab
Nothing changes except the registry host, which is already in CI_REGISTRY_IMAGE. Zaroz pulls the image from inside its cluster, so the registry must be reachable from the internet (or allow Zaroz's egress addresses).
Last modified on
