Skip to content

Allow to Select Kubernetes Namespace in Environment setting page

Problem

For Render Kubernetes resources in Environment inde... (#390769 - closed), users need to specify which namespace to be used for fetching Kubernetes resources.

Proposal

  1. User visits Project > Deployments > Environments. This is Environment index page.
  2. User clicks an environment name, which navigates to Environment details page.
  3. User clicks "Edit" button
  4. User select an namespace from dropdown list.

Prerequisites

To do this, we likely need to finish Authenticate/authorize the user access with bro... (#390767 - closed) for fetching available namespace list.

Permission

It follows update_environment permission. Developer+ is allowed to edit. If the environment is protected, users who are allowed to access can update the environment.

UI

Screenshot_2023-03-29_at_15.45.43

Technical details

  • We add a column to environments table.
# Existing table
environments:
  kubernetes_namespace: string
  • In environment edit page, frontend shows a drop down to select a Kubernetes Namespace. Namespace list can be fetched with kubectl get namespaces Kubernetes API.
  • After the namespace is set, the form is submitted to UpdateEnvironment GraphQL mutation. It's persisted into environments.kubernetes_namespace.
  • The specified kubernetes_namespace is exposed in Types::EnvironmentType, something like:
{
  project(fullPath: "group/project") {
    id
    environment(name: "<environment-name>") {
      slug
      agent {
        id
        name
        project
      }
      kubernetes_namespace
    }
  }
}
Edited by Shinya Maeda