Skip to content

Set kube_context before calling deploy scripts

João Alexandre Cunha requested to merge jcunha-fix-agent-ado into master

What does this MR do and why?

We've introduced a feature to set the kube_context for the Auto DevOps deploy for those that have an agent setup and want to use it to deploy with Auto DevOps. Although, the auto-eploy file, which contains the scripts to do the deploy, depends on the context being already set, otherwise it fails with a message:

"error: current-context must exist in order to minify".

Proposal (chosen here)

The simplest solution is to set the context before anything else.

Other proposal

We could also update the auto-deploy-image script to simply execute the context setting before calling kubectl context minify... right here: https://gitlab.com/gitlab-org/cluster-integration/auto-deploy-image/-/blob/191aac4e9a990d409b7ba5a71f0eda4fe7a98a0a/src/bin/auto-deploy#L16

This would even allow us to not call those - auto-deploy use_kube_context || true on these files, which would make it cleaner code-wise. But on the other hand, we would be executing use_kube_context for every call of every function on that script.

Screenshots or screen recordings

Job with failure example: https://gitlab.com/Alexand/min-ruby-app/-/jobs/1929129555#L25

How to set up and validate locally

  • Setup your Auto DevOps project with an Agent, not a certificate based cluster. Also remember to install ingress, set the base domain, etc...
  • Run an Auto DevOps pipeline and see the job fail like I have.
  • Override your Auto DevOps template to use the one on this MR instead.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by João Alexandre Cunha

Merge request reports