Specify namespace and flux_resource_path in CI job

What does this MR do and why?

This MR enables specifying namespace and flux_resource_path in CI job.

  • environment.kubernetes.namespace: This field was deprecated as this is for the deprecated cert-based integration. But we need this entry for configuring the K8s dashboard. We need to leave the old behavior unchanged if an agent is not set.
  • environment.kubernetesflux_resource_path: This is necessary for configuring the K8s dashboard.

Changelog: added

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.

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

  1. Run GDK.
  2. Create a new project, and register an agent with the following configuration (note that the agent must be able to connect to your GDK, otherwise KAS won't send the configuration through and the authorisations won't be persisted):
 user_access:
   access_as:
     agent: {}
   projects:
     - id: path/to/your/project
  1. Add the following .gitlab-ci.yml, and run a pipeline (remember to substitute the project path and agent name):
stages:
  - deploy

deploy:
  stage: deploy
  environment:
    name: env-$CI_COMMIT_SHORT_SHA
    kubernetes:
      agent: root/verify-mr-173366:verify-mr
      namespace: ns-1
      flux_resource_path: path/to/flux_resource
  script:
    - echo 'deploy'
  1. Go to Operate -> Environments and click on the environment that was just created
  2. Click 'Edit environment', and verify that the agent you created above is listed under 'GitLab agent'
  • Environment was created:

image

  • The environment is attributed with agent, kubernetes_namespace, and flux_resource_path:

image

  • Rails console:
> Environment.find 36
=> #<Environment:0x0000000161e36d60
 id: 36,
 project_id: 34,
 name: "env-b04d4647",
 created_at: Wed, 27 Nov 2024 04:52:20.299818000 UTC +00:00,
 updated_at: Wed, 27 Nov 2024 04:52:35.199703000 UTC +00:00,
 external_url: nil,
 environment_type: nil,
 state: "available",
 slug: "env-b04d4647",
 auto_stop_at: nil,
 auto_delete_at: nil,
 tier: "other",
 merge_request_id: nil,
 cluster_agent_id: 22,
 kubernetes_namespace: "ns-1",
 flux_resource_path: "path/to/flux_resource",
 description: nil,
 description_html: "",
 cached_markdown_version: 2162688>
Edited by Taka Nishida

Merge request reports

Loading