From 8baa4fe2b2b3a03e7a9faf7a8c62c356016854c8 Mon Sep 17 00:00:00 2001 From: Marc LeBlanc <7050295+marcleblanc2@users.noreply.github.com> Date: Wed, 11 Nov 2026 17:11:17 +0000 Subject: [PATCH 01/16] sourcegraph: add labels to PVCs, ServiceAccounts, and RBAC objects Render sourcegraph.labels on the standalone PersistentVolumeClaims, every ServiceAccount, and the prometheus RBAC objects, and add per-component storageLabels and serviceAccount.labels values, so a release that takes over objects created outside the chart can keep the labels they already have. Also fix the jaeger ServiceAccount, which read its name and annotations from a tracing value that does not exist and failed to render. Amp-Thread-ID: https://ampcode.com/threads/T-c7c725c9-ed68-48e2-9f2d-0b8c31e76050 Co-authored-by: Amp --- charts/sourcegraph/CHANGELOG.md | 2 + charts/sourcegraph/README.md | 33 ++ charts/sourcegraph/README.md.gotmpl | 26 ++ charts/sourcegraph/templates/_helpers.tpl | 18 ++ .../blobstore.PersistentVolumeClaim.yaml | 4 + .../blobstore/blobstore.ServiceAccount.yaml | 4 + .../cadvisor/cadvisor.ServiceAccount.yaml | 4 + ...codeinsights-db.PersistentVolumeClaim.yaml | 4 + .../codeinsights-db.ServiceAccount.yaml | 4 + .../codeintel-db.PersistentVolumeClaim.yaml | 4 + .../codeintel-db.ServiceAccount.yaml | 4 + .../frontend/sourcegraph-frontend.Role.yaml | 3 + .../sourcegraph-frontend.RoleBinding.yaml | 3 + .../sourcegraph-frontend.ServiceAccount.yaml | 4 + .../gitserver/gitserver.ServiceAccount.yaml | 4 + .../grafana/grafana.ServiceAccount.yaml | 4 + .../indexed-search.ServiceAccount.yaml | 4 + .../jaeger/jaeger.ServiceAccount.yaml | 8 +- .../node-exporter.ServiceAccount.yaml | 4 + .../otel-agent.ServiceAccount.yaml | 4 + .../otel-collector.ServiceAccount.yaml | 4 + .../pgsql/pgsql.PersistentVolumeClaim.yaml | 4 + .../templates/pgsql/pgsql.ServiceAccount.yaml | 4 + .../worker.ServiceAccount.yaml | 4 + .../prometheus/prometheus.ClusterRole.yaml | 4 + .../prometheus.ClusterRoleBinding.yaml | 4 + .../prometheus.PersistentVolumeClaim.yaml | 4 + .../prometheus/prometheus.RoleBinding.yaml | 4 + .../prometheus/prometheus.ServiceAccount.yaml | 4 + .../redis-cache.PersistentVolumeClaim.yaml | 4 + .../redis/redis-cache.ServiceAccount.yaml | 4 + .../redis-store.PersistentVolumeClaim.yaml | 4 + .../redis/redis-store.ServiceAccount.yaml | 4 + .../searcher/searcher.ServiceAccount.yaml | 4 + .../worker.ServiceAccount.yaml | 4 + .../syntect-server.ServiceAccount.yaml | 4 + .../worker/worker.ServiceAccount.yaml | 4 + .../serviceAccountAnnotations_test.yaml.snap | 15 + .../serviceAccounts_test.yaml.snap | 10 + .../sourcegraph/tests/objectLabels_test.yaml | 283 ++++++++++++++++++ .../tests/serviceAccountAnnotations_test.yaml | 4 + .../tests/serviceAccounts_test.yaml | 4 + charts/sourcegraph/values.yaml | 16 + 43 files changed, 543 insertions(+), 2 deletions(-) create mode 100644 charts/sourcegraph/tests/objectLabels_test.yaml diff --git a/charts/sourcegraph/CHANGELOG.md b/charts/sourcegraph/CHANGELOG.md index a8b444320..e65281048 100644 --- a/charts/sourcegraph/CHANGELOG.md +++ b/charts/sourcegraph/CHANGELOG.md @@ -9,6 +9,8 @@ Use `**BREAKING**:` to denote a breaking change ## Unreleased - 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 `storageLabels` on `blobstore`, `codeInsightsDB`, `codeIntelDB`, `pgsql`, `prometheus`, `redisCache`, and `redisStore` to label each component's PersistentVolumeClaim, and `.serviceAccount.labels` to label a component's ServiceAccount and, for `frontend` and `prometheus`, its Role, RoleBinding, ClusterRole, and ClusterRoleBinding. `sourcegraph.labels` and the chart's standard labels (`helm.sh/chart`, `app.kubernetes.io/name`, `app.kubernetes.io/instance`, `app.kubernetes.io/version`, `app.kubernetes.io/managed-by`) are now also rendered on these PersistentVolumeClaims, on every ServiceAccount, and on the `prometheus` RBAC objects, as they already are on every workload and on the `frontend` Role and RoleBinding, so existing releases gain these labels on upgrade. Labels on these objects can be changed in place, so nothing is recreated or restarted. See [Adopting existing workloads](README.md#adopting-existing-workloads). +- Fixed the `jaeger` ServiceAccount failing to render with `jaeger.serviceAccount.create: true`. Its name and annotations were read from a `tracing` value that does not exist, and are now read from `jaeger.serviceAccount`, as the `jaeger` Deployment's `serviceAccountName` already was. - 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", "