From 7cd9edae30536dc7c502f52ccff61f9aeeb10af2 Mon Sep 17 00:00:00 2001 From: Marc LeBlanc <7050295+marcleblanc2@users.noreply.github.com> Date: Wed, 11 Nov 2026 04:30:52 -0600 Subject: [PATCH 1/2] Add opt-in selector labels to adopt existing workloads Kubernetes does not allow changing a workload's spec.selector or a StatefulSet's volumeClaimTemplates, so a Helm release could not take over workloads created another way, such as with Kustomize, without deleting them. - sourcegraph.selectorLabelsOverride replaces the default app.kubernetes.io/name and app.kubernetes.io/instance selector labels on every component - .extraSelectorLabels adds selector labels to one component - storageLabels on gitserver, grafana, indexedSearch, and searcher adds labels to the volume claim template All default to empty, and the default render is unchanged. Amp-Thread-ID: https://ampcode.com/threads/T-01a1ca07-0283-75f1-837f-d0eb0aa7ee1c Co-authored-by: Amp --- charts/sourcegraph/CHANGELOG.md | 1 + charts/sourcegraph/README.md | 49 ++++ charts/sourcegraph/README.md.gotmpl | 44 +++ charts/sourcegraph/templates/_helpers.tpl | 44 ++- charts/sourcegraph/templates/_worker.tpl | 4 +- .../blobstore/blobstore.Deployment.yaml | 4 +- .../blobstore/blobstore.Service.yaml | 2 +- .../cadvisor/cadvisor.DaemonSet.yaml | 4 +- .../codeinsights-db.Service.yaml | 2 +- .../codeinsights-db.StatefulSet.yaml | 4 +- .../codeintel-db/codeintel-db.Service.yaml | 2 +- .../codeintel-db.StatefulSet.yaml | 4 +- ...sourcegraph-frontend-internal.Service.yaml | 2 +- .../sourcegraph-frontend.Deployment.yaml | 4 +- ...rcegraph-frontend.PodDisruptionBudget.yaml | 2 +- .../sourcegraph-frontend.Service.yaml | 2 +- .../gitserver.PodDisruptionBudget.yaml | 2 +- .../gitserver/gitserver.Service.yaml | 2 +- .../gitserver/gitserver.StatefulSet.yaml | 8 +- .../templates/grafana/grafana.Service.yaml | 2 +- .../grafana/grafana.StatefulSet.yaml | 9 +- .../indexed-search.IndexerService.yaml | 2 +- .../indexed-search.PodDisruptionBudget.yaml | 2 +- .../indexed-search.Service.yaml | 2 +- .../indexed-search.StatefulSet.yaml | 7 +- .../node-exporter.DaemonSet.yaml | 4 +- .../node-exporter/node-exporter.Service.yaml | 2 +- .../otel-collector/otel-agent.DaemonSet.yaml | 4 +- .../otel-collector.Deployment.yaml | 4 +- .../otel-collector.Service.yaml | 2 +- .../templates/pgsql/pgsql.Service.yaml | 2 +- .../templates/pgsql/pgsql.StatefulSet.yaml | 4 +- .../precise-code-intel/worker.Deployment.yaml | 4 +- .../worker.PodDisruptionBudget.yaml | 2 +- .../precise-code-intel/worker.Service.yaml | 2 +- .../prometheus/prometheus.Deployment.yaml | 4 +- .../prometheus/prometheus.Service.yaml | 2 +- .../redis/redis-cache.Deployment.yaml | 4 +- .../redis-cache.PodDisruptionBudget.yaml | 2 +- .../templates/redis/redis-cache.Service.yaml | 2 +- .../redis/redis-store.Deployment.yaml | 4 +- .../redis-store.PodDisruptionBudget.yaml | 2 +- .../templates/redis/redis-store.Service.yaml | 2 +- .../searcher.PodDisruptionBudget.yaml | 2 +- .../templates/searcher/searcher.Service.yaml | 2 +- .../searcher/searcher.StatefulSet.yaml | 8 +- .../worker.Deployment.yaml | 4 +- .../worker.PodDisruptionBudget.yaml | 2 +- .../syntactic-code-intel/worker.Service.yaml | 2 +- .../syntect-server.Deployment.yaml | 4 +- .../syntect-server.PodDisruptionBudget.yaml | 2 +- .../syntect-server.Service.yaml | 2 +- .../worker/worker-executors.Service.yaml | 2 +- .../worker/worker.PodDisruptionBudget.yaml | 2 +- .../templates/worker/worker.Service.yaml | 2 +- .../tests/selectorLabels_test.yaml | 256 ++++++++++++++++++ charts/sourcegraph/values.yaml | 21 ++ 57 files changed, 499 insertions(+), 74 deletions(-) create mode 100644 charts/sourcegraph/tests/selectorLabels_test.yaml diff --git a/charts/sourcegraph/CHANGELOG.md b/charts/sourcegraph/CHANGELOG.md index 12550ffa1..a8b444320 100644 --- a/charts/sourcegraph/CHANGELOG.md +++ b/charts/sourcegraph/CHANGELOG.md @@ -9,6 +9,7 @@ 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 `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", "