Switch Kubernetes metrics autodetection to per namespace
Problem to solve
Presently we only show Kubernetes system metrics if we are able to detect the environment based on the Pod/Deployment names. This is because Auto DevOps, and potentially others but not commonly, deploy multiple environments to the same Kubernetes namespace. Because multiple environments could deploy into the same namespace, we need to utilize the pod names to differentiate environments within a namespace.
Soon, ADO plans to deploy environments to their own namespace. When this happens, we should also adjust our detection to support more use cases without requiring special naming formats.
Intended users
Further details
Original Proposal
Support per-namespace matching for environments, removing the need for any special naming conventions. Essentially the k8s system metrics PromQL should filter based on the namespace, without the current matching rules for pod names.
Since this is a change in functionality, it should probably be opt-in for now. In a major release we could then make this the default. (Potentially 12.0)
Updated Proposal
- The plan in https://gitlab.com/gitlab-org/gitlab-ce/issues/52494 is to have a setting in BE (not displayed on FE) which controls if namespaces are created per environment. It will be disabled for existing clusters and enabled for new clusters.
- We can use that setting to determine if we should use per-namespace matching for environments. So, if it is enabled, we will use per-namespace matching for environments.