This page contains information related to upcoming products, features, and functionality. It is important to note that the information presented is for informational purposes only. Please do not rely on this information for purchasing or planning purposes. As with all projects, the items mentioned on this page are subject to change or delay. The development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.
Status Authors Coach DRIs Owning Stage Created
implemented @shinya.maeda @DylanGriffith @nagyv-gitlab @cbalane @hustewart @hfyngvason devops deploy 2022-11-23

View and manage resources deployed by GitLab agent For Kubernetes

Summary

As part of the GitLab Kubernetes Dashboard epic, users want to view and manage their resources deployed by GitLab agent For Kubernetes. Users should be able to interact with the resources through GitLab UI, such as Environment Index/Details page.

This blueprint describes how the association is established and how these domain models interact with each other.

Motivation

Goals

Non-Goals

Proposal

Overview

  • GitLab Environment and GitLab agent For Kubernetes have 1-to-1 relationship.
  • GitLab Environment tracks all resources produced by the connected agent. This includes not only resources written in manifest files but also subsequently generated resources (for example, Pods created by Deployment manifest file).
  • GitLab Environment renders dependency graph, such as Deployment => ReplicaSet => Pod. This is for providing ArgoCD-style resource view.
  • GitLab Environment has the Resource Health status that represents a summary of resource statuses, such as Healthy, Progressing or Degraded.
flowchart LR subgraph Kubernetes["Kubernetes"] subgraph ResourceGroupProduction["Production"] direction LR ResourceGroupProductionService(["Service"]) ResourceGroupProductionDeployment(["Deployment"]) ResourceGroupProductionPod1(["Pod1"]) ResourceGroupProductionPod2(["Pod2"]) end subgraph ResourceGroupStaging["Staging"] direction LR ResourceGroupStagingService(["Service"]) ResourceGroupStagingDeployment(["Deployment"]) ResourceGroupStagingPod1(["Pod1"]) ResourceGroupStagingPod2(["Pod2"]) end end subgraph GitLab subgraph Organization subgraph Project environment1["production environment"] environment2["staging environment"] end end end environment1 --- ResourceGroupProduction environment2 --- ResourceGroupStaging ResourceGroupProductionService -.- ResourceGroupProductionDeployment ResourceGroupProductionDeployment -.- ResourceGroupProductionPod1 ResourceGroupProductionDeployment -.- ResourceGroupProductionPod2 ResourceGroupStagingService -.- ResourceGroupStagingDeployment ResourceGroupStagingDeployment -.- ResourceGroupStagingPod1 ResourceGroupStagingDeployment -.- ResourceGroupStagingPod2

Existing components and relationships

Issues

  • GitLab Environment should have ID of GitLab agent For Kubernetes as the foreign key.
  • GitLab Environment should have parameters how to group resources in the associated cluster, for example, namespace, lable and inventory-id (GitOps mode only) can passed as parameters.
  • GitLab Environment should be able to fetch all relevant resources, including both default resource kinds and other Custom Resources.
  • GitLab Environment should be aware of dependency graph.
  • GitLab Environment should be able to compute Resource Health status from the associated resources.

Example

This is an example of how the architecture works in push-based deployment. The feature is documented here as CI access mode.

flowchart LR subgraph ProductionKubernetes["Production Kubernetes"] subgraph ResourceGroupProductionFrontend["Production"] direction LR ResourceGroupProductionFrontendService(["Service"]) ResourceGroupProductionFrontendDeployment(["Deployment"]) ResourceGroupProductionFrontendPod1(["Pod1"]) ResourceGroupProductionFrontendPod2(["Pod2"]) end subgraph ResourceGroupProductionBackend["Staging"] direction LR ResourceGroupProductionBackendService(["Service"]) ResourceGroupProductionBackendDeployment(["Deployment"]) ResourceGroupProductionBackendPod1(["Pod1"]) ResourceGroupProductionBackendPod2(["Pod2"]) end subgraph ResourceGroupProductionPrometheus["Monitoring"] direction LR ResourceGroupProductionPrometheusService(["Service"]) ResourceGroupProductionPrometheusDeployment(["Deployment"]) ResourceGroupProductionPrometheusPod1(["Pod1"]) ResourceGroupProductionPrometheusPod2(["Pod2"]) end end subgraph GitLab subgraph Organization subgraph OperationGroup subgraph AgentManagementProject AgentManagementAgentProduction["Production agent"] AgentManagementManifestFiles["Kubernetes Manifest Files"] AgentManagementEnvironmentProductionPrometheus["production prometheus environment"] AgentManagementPipelines["CI/CD pipelines"] end end subgraph DevelopmentGroup subgraph FrontendAppProject FrontendAppCode["VueJS"] FrontendDockerfile["Dockerfile"] end subgraph BackendAppProject BackendAppCode["Golang"] BackendDockerfile["Dockerfile"] end subgraph DeploymentProject DeploymentManifestFiles["Kubernetes Manifest Files"] DeploymentPipelines["CI/CD pipelines"] DeploymentEnvironmentProductionFrontend["production frontend environment"] DeploymentEnvironmentProductionBackend["production backend environment"] end end end end DeploymentEnvironmentProductionFrontend --- ResourceGroupProductionFrontend DeploymentEnvironmentProductionBackend --- ResourceGroupProductionBackend AgentManagementEnvironmentProductionPrometheus --- ResourceGroupProductionPrometheus ResourceGroupProductionFrontendService -.- ResourceGroupProductionFrontendDeployment ResourceGroupProductionFrontendDeployment -.- ResourceGroupProductionFrontendPod1 ResourceGroupProductionFrontendDeployment -.- ResourceGroupProductionFrontendPod2 ResourceGroupProductionBackendService -.- ResourceGroupProductionBackendDeployment ResourceGroupProductionBackendDeployment -.- ResourceGroupProductionBackendPod1 ResourceGroupProductionBackendDeployment -.- ResourceGroupProductionBackendPod2 ResourceGroupProductionPrometheusService -.- ResourceGroupProductionPrometheusDeployment ResourceGroupProductionPrometheusDeployment -.- ResourceGroupProductionPrometheusPod1 ResourceGroupProductionPrometheusDeployment -.- ResourceGroupProductionPrometheusPod2 AgentManagementAgentProduction -- Shared with --- DeploymentProject DeploymentPipelines -- "Deploy" --> ResourceGroupProductionFrontend DeploymentPipelines -- "Deploy" --> ResourceGroupProductionBackend AgentManagementPipelines -- "Deploy" --> ResourceGroupProductionPrometheus

Further details

Multi-Project Deployment Pipelines

The microservice project setup can be improved by Multi-Project Deployment Pipelines:

  • Deployment Project can behave as the shared deployment engine for any upstream application projects and environments.
  • Environments can be created within the application projects. It gives more visibility of environments for developers.
  • Deployment Project can be managed under Operator group. More segregation of duties.
  • Users don’t need to set up RBAC to restrict CI/CD jobs.
  • This is especitially helpful for dynamic environments, such as Review Apps.
flowchart LR subgraph ProductionKubernetes["Production Kubernetes"] subgraph ResourceGroupProductionFrontend["Frontend"] direction LR ResourceGroupProductionFrontendService(["Service"]) ResourceGroupProductionFrontendDeployment(["Deployment"]) ResourceGroupProductionFrontendPod1(["Pod1"]) ResourceGroupProductionFrontendPod2(["Pod2"]) end subgraph ResourceGroupProductionBackend["Backend"] direction LR ResourceGroupProductionBackendService(["Service"]) ResourceGroupProductionBackendDeployment(["Deployment"]) ResourceGroupProductionBackendPod1(["Pod1"]) ResourceGroupProductionBackendPod2(["Pod2"]) end subgraph ResourceGroupProductionPrometheus["Monitoring"] direction LR ResourceGroupProductionPrometheusService(["Service"]) ResourceGroupProductionPrometheusDeployment(["Deployment"]) ResourceGroupProductionPrometheusPod1(["Pod1"]) ResourceGroupProductionPrometheusPod2(["Pod2"]) end end subgraph GitLab subgraph Organization subgraph OperationGroup subgraph DeploymentProject DeploymentAgentProduction["Production agent"] DeploymentManifestFiles["Kubernetes Manifest Files"] DeploymentEnvironmentProductionPrometheus["production prometheus environment"] DeploymentPipelines["CI/CD pipelines"] end end subgraph DevelopmentGroup subgraph FrontendAppProject FrontendDeploymentPipelines["CI/CD pipelines"] FrontendEnvironmentProduction["production environment"] end subgraph BackendAppProject BackendDeploymentPipelines["CI/CD pipelines"] BackendEnvironmentProduction["production environment"] end end end end FrontendEnvironmentProduction --- ResourceGroupProductionFrontend BackendEnvironmentProduction --- ResourceGroupProductionBackend DeploymentEnvironmentProductionPrometheus --- ResourceGroupProductionPrometheus ResourceGroupProductionFrontendService -.- ResourceGroupProductionFrontendDeployment ResourceGroupProductionFrontendDeployment -.- ResourceGroupProductionFrontendPod1 ResourceGroupProductionFrontendDeployment -.- ResourceGroupProductionFrontendPod2 ResourceGroupProductionBackendService -.- ResourceGroupProductionBackendDeployment ResourceGroupProductionBackendDeployment -.- ResourceGroupProductionBackendPod1 ResourceGroupProductionBackendDeployment -.- ResourceGroupProductionBackendPod2 ResourceGroupProductionPrometheusService -.- ResourceGroupProductionPrometheusDeployment ResourceGroupProductionPrometheusDeployment -.- ResourceGroupProductionPrometheusPod1 ResourceGroupProductionPrometheusDeployment -.- ResourceGroupProductionPrometheusPod2 FrontendDeploymentPipelines -- "Trigger downstream pipeline" --> DeploymentProject BackendDeploymentPipelines -- "Trigger downstream pipeline" --> DeploymentProject DeploymentPipelines -- "Deploy" --> ResourceGroupProductionFrontend DeploymentPipelines -- "Deploy" --> ResourceGroupProductionBackend

Design and implementation details

Associate Environment with Agent

Users can explicitly set a GitLab agent For Kubernetes to a GitLab Environment in setting UI. Frontend will use this associated agent for authenticating/authorizing the user access, which is described in a latter section.

We need to adjust the read_cluster_agent permission in DeclarivePolicy for supporting agents shared by an external project (also known as the Agent management project).

Fetch resources through user_access

When user visits an environment page, GitLab frontend fetches an environment via GraphQL. Frontend additionally fetches the associated agent-ID and namespace.

Here is an example of GraphQL query:

{
  project(fullPath: "group/project") {
    id
    environment(name: "<environment-name>") {
      slug
      kubernetesNamespace
      clusterAgent {
        id
        name
        project {
          name
        }
      }
    }
  }
}

GitLab frontend authenticate/authorize the user access with browser cookie. If the access is forbidden, frontend shows an error message that You don't have access to an agent that deployed to this environment. Please contact agent administrator if you are allowed in "user_access" in agent config file. See <troubleshooting-doc-link>.

After the user gained access to the agent, GitLab frontend fetches specific Resource kinds (for example, Deployment, Pod) in the Kubernetes with the following parameters:

  • namespace#{environment.kubernetesNamespace}

If no resources are found, this is likely that the users have not embedded these lables into their resources. In this case, frontend shows an warning message There are no resources found for the environment. Do resources have GitLab preserved labels? See <troubleshooting-doc-link>.

Dependency graph

  • GitLab frontend uses Owner References to idenfity the dependencies between resources. These are embedded in resources as metadata.ownerReferences field.
  • For the resoruces that don’t have owner references, we can use Well-Known Labels, Annotations and Taints as complement. for example, EndpointSlice doesn’t have metadata.ownerReferences, but has kubernetes.io/service-name as a reference to the parent Service resource.

Health status of resources

  • GitLab frontend computes the status summary from the fetched resources. Something similar to ArgoCD’s Resource Health for example, Healthy, Progressing, Degraded and Suspended. The formula is TBD.