Can not overwrite default template
Summary
When using managed Kubernetes resources, I can not redefine the default template
Steps to reproduce
- Create a project, register an agent, enable managed resources
- Create a new
environment_templates/default.yamlunder the agent config directory with the following content:
objects:
- apiVersion: v1
kind: Namespace
metadata:
name: 'nagyv-{{ .ci_pipeline.id }}-{{ .ci_job.id }}'
# Resource lifecycle configuration
apply_resources: on_start # Resources are applied when environment is started/restarted
delete_resources: on_stop # Resources are removed when environment is stopped
- Create a
.gitlab-ci.ymlwith the following content, use yourAGENT_CONTEXTvalue
test_managed_resource:
image: portainer/kubectl-shell:2.26.1
variables:
AGENT_CONTEXT: gitlab-org/ci-cd/deploy-stage/demos/infra-platform:demo-dev
before_script:
- kubectl config get-contexts
- kubectl config use-context $AGENT_CONTEXT
script:
- kubectl auth can-i --list
environment:
name: test-${CI_PIPELINE_IID}
kubernetes:
agent: $AGENT_CONTEXT
- Run the pipeline
- Check out the namespace name in the cluster
Example Project
- default template defintion in: https://gitlab.com/gitlab-org/ci-cd/deploy-stage/demos/infra-platform/-/blob/main/.gitlab/agents/demo-dev/envrionment_templates/default.yaml
- pipeline definition in https://gitlab.com/gitlab-org/ci-cd/deploy-stage/demos/auto-devops
What is the current bug behavior?
The created namespace follows the built-in default template pattern, not the custom one
What is the expected correct behavior?
The namespace name should follow the custom pattern
Relevant logs and/or screenshots
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)(we will only investigate if the tests are passing)
Possible fixes
Edited by Taka Nishida