Repository navigation
feat/labels: Apply sourcegraph.labels to all objects in all four charts - #1023
Draft
marcleblanc2 wants to merge 18 commits into
Draft
marcleblanc2 wants to merge 18 commits into
marcleblanc2 wants to merge 18 commits into
Conversation
marcleblanc2
force-pushed
the
marc/labels-every-object
branch
from
November 18, 2026 18:41
a6f223d to
2dacb93
Compare
marcleblanc2
force-pushed
the
marc/labels-every-object
branch
from
November 18, 2026 19:54
2dacb93 to
38c24c0
Compare
marcleblanc2
force-pushed
the
marc/labels-every-object
branch
from
November 18, 2026 20:08
38c24c0 to
5a76434
Compare
Services, ConfigMaps, Secrets, the Ingress, PodDisruptionBudgets, PriorityClasses, and extraResources of the sourcegraph chart did not render sourcegraph.labels. Neither did any object of the sourcegraph-executor-k8s chart, nor the docker-config ConfigMap and private-docker-registry Service of the sourcegraph-executor-dind chart. Prometheus copies Service labels to the metrics it scrapes, so its bundled configuration now drops the chart's standard labels: helm.sh/chart and app.kubernetes.io/version change on every upgrade. Each chart gets a test that renders every template and checks the labels, so a template added later is covered too. Amp-Thread-ID: https://ampcode.com/threads/T-c7c725c9-ed68-48e2-9f2d-0b8c31e76050 Co-authored-by: Amp <amp@ampcode.com>
The redis-store ServiceAccount was the only one that did not include the annotations helper, so redisStore.serviceAccount.annotations was silently dropped. Amp-Thread-ID: https://ampcode.com/threads/T-c7c725c9-ed68-48e2-9f2d-0b8c31e76050 Co-authored-by: Amp <amp@ampcode.com>
PodDisruptionBudgets, PriorityClasses, the StorageClass, the test Pod, and the k8s executor Secret now have deploy and app.kubernetes.io/component labels, and the jaeger objects have app.kubernetes.io/instance. <serviceName>.labels and executor.labels are also rendered on a component's ConfigMaps, Secrets, and PodDisruptionBudget. Adds storageClass.labels, priorityClasses[].labels, and privateDockerRegistry.serviceLabels (dind). Amp-Thread-ID: https://ampcode.com/threads/T-c7c725c9-ed68-48e2-9f2d-0b8c31e76050 Co-authored-by: Amp <amp@ampcode.com>
…ice with its app
The bundled Prometheus copies Service labels to the metrics it scrapes. Now
that every Service has sourcegraph.labels, the labeldrop rule also drops
those keys, so the labels of Service-scraped metrics stay as they are on main.
The rule no longer drops app.kubernetes.io/managed-by: Helm adds that label
to every object it installs, so the metrics already had it.
The otel-collector Service had no app label, unlike every other scraped
Service, so its metrics had no app and job labels and the dashboard's
up{app=~".*otel-collector"} panel and alert had no data.
Amp-Thread-ID: https://ampcode.com/threads/T-c7c725c9-ed68-48e2-9f2d-0b8c31e76050
Co-authored-by: Amp <amp@ampcode.com>
The image's logging.yaml, and the ConfigMap the chart renders for custom exporters, left the collector's metrics on 127.0.0.1:8888, where Prometheus cannot scrape them. With the app label the Service gained, up was 0 and the pods available alert fired instead of showing no data. Pass the telemetry readers setting as a second --config to the default command, and add it to the rendered ConfigMap. jaeger.yaml already has it. Amp-Thread-ID: https://ampcode.com/threads/T-c7c725c9-ed68-48e2-9f2d-0b8c31e76050 Co-authored-by: Amp <amp@ampcode.com>
…rics to be scraped openTelemetry.gateway.command replaces the default command, so it does not get the argument that serves the collector's metrics on all interfaces. Amp-Thread-ID: https://ampcode.com/threads/T-c7c725c9-ed68-48e2-9f2d-0b8c31e76050 Co-authored-by: Amp <amp@ampcode.com>
Pod templates now get `sourcegraph.labels`, the chart's standard labels, and `app.kubernetes.io/component`, as every other object does. One helper, `sourcegraph.podLabels`, merges them with `sourcegraph.podLabels`, the component's `podLabels`, and the selector labels, so each key is rendered once and a selector label always wins. The Prometheus `labeldrop` rule now also drops `app.kubernetes.io/managed-by` and also applies to the `kubernetes-pods` job, so Helm and `helm template | kubectl apply` installs get the same metric labels. No bundled dashboard or alert queries the dropped labels. The changelog no longer asks for a manual Prometheus restart: the `checksum/prometheus-config` annotation restarts it. Amp-Thread-ID: https://ampcode.com/threads/T-01a1cc03-93a7-7445-8f1f-3dd7123272bf Co-authored-by: Amp <amp@ampcode.com>
The setting that serves the collector's own metrics on all interfaces was part of the default command, so a command set in `openTelemetry.gateway.command` did not get it, and Prometheus could not scrape the collector. It is now always the last container argument, after `openTelemetry.gateway.args`, so a replacement command gets it too. Last, so that it is `$0` of a `sh -c` command whose script is the first argument. Amp-Thread-ID: https://ampcode.com/threads/T-01a1cc03-93a7-7445-8f1f-3dd7123272bf Co-authored-by: Amp <amp@ampcode.com>
The collector does not reload a changed ConfigMap by itself, so a change to openTelemetry.gateway.config.traces took effect only at the pod's next restart. The pod template now has a checksum/otel-collector-config annotation over those values, which are all the ConfigMap's data is rendered from. It is set only when the chart renders the ConfigMap, so the default install does not change. Amp-Thread-ID: https://ampcode.com/threads/T-01a1cc03-93a7-7445-8f1f-3dd7123272bf Co-authored-by: Amp <amp@ampcode.com>
helm.sh/chart and app.kubernetes.io/version change with every chart version. As pod labels they changed every pod template, so every pod restarted whenever the chart version changed, even when nothing else did. On main no pod template depends on the chart version. Pod templates in all four charts now get the common labels without these two. The other objects keep them. This also updates the pod label snapshots of the selector labels golden test: every pod gains app.kubernetes.io/managed-by and app.kubernetes.io/component, and no selector, volume claim template, or existing pod label changes. Amp-Thread-ID: https://ampcode.com/threads/T-01a1cc03-93a7-7445-8f1f-3dd7123272bf Co-authored-by: Amp <amp@ampcode.com>
Each chart's label defines, with their comments, move unchanged out of _helpers.tpl, next to the other one-topic helper files. Renders are byte-identical. Amp-Thread-ID: https://ampcode.com/threads/T-01a1d360-e0b4-71d1-8ded-2e4851b93a8d Co-authored-by: Amp <amp@ampcode.com>
The jaeger-collector and jaeger-query Services select on app.kubernetes.io/instance: <release name>. main pins that label on the jaeger pod. Once the pod also renders sourcegraph.podLabels and jaeger.podLabels, a value for that label in either replaced the release name, and both Services lost their endpoints. Merge the release name last, and test that the pod keeps every label the Services select on. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a1902b-ece9-725c-863d-3e2bba35ee1d
…gument on With the script as the first of openTelemetry.gateway.args after command: ["/bin/sh", "-c"], the chart's argument is $0 and "$@" is empty, so a wrapper that passes only "$@" drops it and the collector keeps serving its metrics on 127.0.0.1. Document "$0" "$@" for that form and "$@" for a script in command followed by a placeholder, and use the first in the test. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a1902b-ece9-725c-863d-3e2bba35ee1d
executor.storage.labels labels the scratch PersistentVolumeClaim that is created when executor.storage.type is ephemeral, as storageLabels does for the PersistentVolumeClaims of the sourcegraph chart. It defaults to empty, so existing releases render the same pods. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a1902b-ece9-725c-863d-3e2bba35ee1d
…VC labels privateDockerRegistry.storageLabels adds labels to the cache volume claim template of the private-docker-registry StatefulSet, the last PersistentVolumeClaim in the four charts that had no label value. It defaults to empty, so existing releases render the same template. The README now says which values label each PersistentVolumeClaim of the chart, and that the registry's cannot change on an installed release. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a1902b-ece9-725c-863d-3e2bba35ee1d
The scratch PersistentVolumeClaim of preciseCodeIntel and syntacticCodeIntel (storageType: pvc) and of the dind executor (executor.storage.type: ephemeral) now gets sourcegraph.labels, the standard Helm labels, deploy, and app.kubernetes.io/component, as the standalone PersistentVolumeClaims do, in addition to its own storageLabels or executor.storage.labels. These labels are part of the pod template and include the chart version, so with those settings the pods restart whenever the chart version changes. Default renders are unchanged: the default volume is an emptyDir. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a1902b-ece9-725c-863d-3e2bba35ee1d
marcleblanc2
force-pushed
the
marc/labels-every-object
branch
from
November 18, 2026 20:32
6cda7a2 to
591d864
Compare
sourcegraph.otelCollector.metricsReaders moves to _helpers/_otelCollector.tpl, and the dind chart's executor.deployment moves to _helpers/_executorDeployment.tpl, each with its comment and otherwise unchanged. No _helpers.tpl gains a line on this branch any more: every helper it adds or changes is in a one-topic file under _helpers/. Renders are byte-identical. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a1902b-ece9-725c-863d-3e2bba35ee1d
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft until
--configargument replacesservice.telemetry.metrics.readersin a custom command's config file. Should the readers be a Helm value instead?sourcegraph.labelsand a per-component value renders twice, as it already does onmainfor workloads. Helm accepts it,kubeconform -strictdoes notProblem
sourcegraph.labelsSolution
sourcegraph.labels, the standard Helm labels,deploy, andapp.kubernetes.io/componenton every object<serviceName>.labelsandexecutor.labelscover more objects. New:storageClass.labels,priorityClasses[].labels,privateDockerRegistry.serviceLabels<serviceName>.storageLabels. Kubernetes rejects changes to those templates, so adding labels would fail the upgrade of existing releasespreciseCodeIntelandsyntacticCodeIntelwithstorageType: pvc, dindexecutor.storage.type: ephemeral) get the same labels as the standalone PVCs, includinghelm.sh/chartandapp.kubernetes.io/versionexecutor.storage.labelsfor the scratch PVC, and newprivateDockerRegistry.storageLabelsfor the registry's volume claim template. Both default to empty. Its README has a new "PersistentVolumeClaim labels" section_helpers.tplgains a line: every helper this PR adds or changes is in a one-topic file under_helpers/. The dind chart'sexecutor.deploymentmoved whole to_helpers/_executorDeployment.tpl, so its diff shows as a new file; its real changes are the pod labels and the scratch PVC's labelslabeldroprule keeps the new labels off metricsprometheusrestarts when its config changes, andotel-collectordoes whenopenTelemetry.gateway.config.traces.exportersis setredisStore.serviceAccount.annotationswas droppedapp.kubernetes.io/instancepod label left the Jaeger Services with no endpointsUpgrade impact
helm.sh/chartorapp.kubernetes.io/version. The exception is a pod with a scratch PVC (the settings above): its PVC labels are in the pod template and include the chart version, so it restarts on every chart version changeprometheus.existingConfig, add thelabeldroprule yourselfopenTelemetry.gateway.commandmust pass the chart's last argument on;values.yamlsays howTested
helm unittest(293, 11, 10, and 13 tests),helm lint, helm-docs, andkubeconform -strictpassapp_kubernetes_io_managed_by, and theotel-collectortargets went from down to upAmp threads
Changelog
sourcegraph.labels, the standard Helm labels,deploy, andapp.kubernetes.io/componentare now on every object in all four chartsstorageClass.labels,priorityClasses[].labels,privateDockerRegistry.serviceLabels, and in the dind chartexecutor.storage.labelsandprivateDockerRegistry.storageLabelsprometheus.existingConfig, add the newlabeldroprule to keep the labels off metricsredisStore.serviceAccount.annotations, and the OpenTelemetry Collector "pods available" alert