From f31d9722655acadd36f48829e4c48ce4052470c9 Mon Sep 17 00:00:00 2001 From: Marc LeBlanc <7050295+marcleblanc2@users.noreply.github.com> Date: Thu, 12 Nov 2026 17:01:28 -0600 Subject: [PATCH 1/7] Default prometheus.privileged to false and scope pod and service discovery to the release namespace A default install granted the prometheus ServiceAccount cluster-wide read access, including nodes/proxy, to run two scrape jobs whose metrics no Sourcegraph dashboard or alert uses. It now creates only a RoleBinding to the built-in view ClusterRole in the release namespace. The kubernetes-pods and kubernetes-services jobs listed pods and services in every namespace, which the view RoleBinding does not allow, so with privileged=false they failed and pod-annotated targets such as cadvisor were never scraped. They now list only the release namespace, as kubernetes-service-endpoints already did. Amp-Thread-ID: https://ampcode.com/threads/T-01a1d140-e6de-7173-8b4f-187543b7833c Co-authored-by: Amp --- charts/sourcegraph/CHANGELOG.md | 2 + charts/sourcegraph/README.md | 4 +- .../examples/openshift/override.yaml | 7 +- charts/sourcegraph/templates/NOTES.txt | 11 --- .../prometheus/prometheus.ConfigMap.yaml | 6 ++ .../tests/prometheusPrivileged_test.yaml | 94 +++++++++++++++++-- charts/sourcegraph/values.yaml | 11 ++- 7 files changed, 107 insertions(+), 28 deletions(-) diff --git a/charts/sourcegraph/CHANGELOG.md b/charts/sourcegraph/CHANGELOG.md index a8b444320..67c853785 100644 --- a/charts/sourcegraph/CHANGELOG.md +++ b/charts/sourcegraph/CHANGELOG.md @@ -8,6 +8,8 @@ Use `**BREAKING**:` to denote a breaking change ## Unreleased +- **BREAKING**: `prometheus.privileged` now defaults to `false`. A default install creates one RoleBinding from the `prometheus` ServiceAccount to the built-in `view` ClusterRole in the release namespace, instead of a ClusterRole and ClusterRoleBinding that grant cluster-wide read access, including `nodes/proxy`. Prometheus no longer runs the `kubernetes-apiservers` and `kubernetes-nodes` scrape jobs, whose metrics no Sourcegraph dashboard or alert uses. Upgrading a release that does not set `prometheus.privileged` deletes the `prometheus` ClusterRole and ClusterRoleBinding and creates the RoleBinding; set `prometheus.privileged: true` to keep the previous RBAC resources and scrape jobs. +- **BREAKING**: The `kubernetes-pods` and `kubernetes-services` Prometheus scrape jobs now discover targets only in the release namespace, as `kubernetes-service-endpoints` already did, including when `prometheus.privileged` is `true`. Pods annotated `sourcegraph.prometheus/scrape: "true"` in other namespaces are no longer scraped. With `prometheus.privileged: false`, these jobs previously failed to list pods and services cluster-wide, so pod-annotated targets such as `cadvisor` were not scraped; they are now. The `prometheus.privileged` warning is removed from the install notes. - The `correct-data-dir-permissions` init containers of `pgsql`, `codeintel-db`, and `codeinsights-db` now run the database's own image instead of `sourcegraph/alpine-3.14`, which was based on an end-of-life Alpine release. The chart no longer pulls `alpine-3.14`, so private registries no longer need to mirror it. `alpine.image` has been removed and is ignored if set; `alpine.containerSecurityContext`, `alpine.resources`, and `codeInsightsDB.init.containerSecurityContext` still apply. - Added `sourcegraph.selectorLabelsOverride`, `.extraSelectorLabels`, and `storageLabels` on `gitserver`, `grafana`, `indexedSearch`, and `searcher`, so the chart can render the selectors and volume claim templates of workloads created outside it, such as with Kustomize, and a Helm release can take them over without deleting them. All default to empty, so existing releases render the same selectors. Never change them on an installed release: Kubernetes does not allow changing these fields. See [Adopting existing workloads](README.md#adopting-existing-workloads). - Fixed `frontend.command` and `migrator.command` rendering a list as a single element, e.g. `["sh", "-c", "