I deploy an sample project to a minikube k8s cluster via gitlab. I want gitlab (or my CI script) to stop the old deployment/environment before deploying the new one. (to prevent issues when renaming something in k8s.yaml files)
The corresponding build steps look something like this:
deploy:
image: dtzar/helm-kubectl
stage: deploy
only:
kubernetes: active
environment:
name: definitelynotproduction
on_stop: stop_deployment
script:
- kubectl apply -f ...
To stop this deployment/environment I also created an stop stage:
stop_deployment:
image: dtzar/helm-kubectl
stage: stop_deployment
only:
kubernetes: active
needs: ["deploy"]
when: manual
environment:
name: definitelynotproduction
action: stop
script:
- kubectl delete -f ...
How to achieve a clean shutdown of the old environment? Since Gitlab is not calling the stop job automatically (only by hand, or according to docs when a branch is deleted).