Review environments deployed in kube, and Gitlab agent

Problem to solve

We use the Kubernetes GitLab agent in our project to get it deployed in review environment. It works great, but when we check the environment created by the review, it isn’t linked to the Gitlab agent, thus leaving the tab “Kubernetes dashboard” empty.

It’s up to the user to edit the environment and select the GitLab agent. We’d like to avoid this step and have the GitLab agent already set up so that the dashboard is filled with the correct items.

Steps to reproduce

  • Deploy an environment using Kubernetes
  • Go to the environment page
  • The Kubernetes dashboard says “No Kubernetes clusters configured”
  • Need to click on “Edit environment” and select the GitLab agent
    , and afterwards select the namespace.

Configuration

Our code for the job is the following

deploy:review-app:
  stage: deploy
  interruptible: true
  image: ...
  variables:
    DASHBOARD_URL: https://dashboard-$CI_MERGE_REQUEST_IID.review-apps.mycompany.tech
    HELM_NAMESPACE: gimreviewapp-$CI_MERGE_REQUEST_IID
  rules:
    - if: $CI_MERGE_REQUEST_LABELS !~ /deploy_review_app_gitlab/
      when: never
  script:
    - helm upgrade --install gim-$CI_MERGE_REQUEST_IID $CI_PROJECT_DIR/review_app/chart --create-namespace --wait --timeout=20m
  environment:
    name: review-app/$CI_COMMIT_REF_NAME
    url: $DASHBOARD_URL
    on_stop: deploy:stop_review
    kubernetes:
      namespace: $HELM_NAMESPACE

Versions

Please select whether options apply, and add the version information.

  • Self-managed
  • GitLab.com SaaS
  • Self-hosted Runners

GitLab Enterprise Edition v17.0.1-ee