Generate cluster resources
What does this MR do and why?
Generate cluster resources.
Add a new class under the prerequisite, that will be executed just before the CI pipeline starts. #complete! method calls KAS three (or four) times to complete the process. (1) Get the template, (2) Render the template, and (3) Apply the template.
It does NOT support:
-
resource_management.enabledflag. This will be supported in the follow-up MR. - Detailed error information. (Follow-up issue: Better error information for GitLab-managed Kub... (#513694))
- Custom template file name. (Will be supported in the future)
References
Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
- Part of #507268 (closed)
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
| Before | After |
|---|---|
How to set up and validate locally
- Run GDK. Stop KAS. (
gdk start && gdk stop gitlab-k8s-agent) - Run KAS with the latest master branch in your local. (See Running Kas and agentk locally)
- Set up a example project, and connect it to the gitlab agent. Add agent config file and allow ci_access to the agent.(Authorize the agent to access your projects) For example:
ci_access:
projects:
- id: path/to/project
- Add CI job
.gitlab-ci.yml
deploy:
image:
name: bitnami/kubectl:latest
entrypoint: ['']
environment:
name: env1 # Change to your environment name
deployment_tier: staging
script:
- kubectl config get-contexts
- kubectl get ns
- Modify
resource_management_enabled?method to returntrueto verify this prerequisite works correctly. Leave it as-is so that you can make sure it won't work and nothing changes from current behavior. - Push commit and run CI pipeline.
- If
resource_management_enabled?method is updated to return true, it will execute the newly added prerequisite class. That will communicate with KAS and apply environment template. The default template will create the namespace (e.g.env1-24-5) and role binding. Ifresource_management_enabled?method returns false, it does nothing.