Skip to content

feat/labels: Add labels to PVCs, ServiceAccounts, and RBAC objects - #1008

Draft
marcleblanc2 wants to merge 1 commit into
mainfrom
marc/pvc-serviceaccount-labels
Draft

marcleblanc2 wants to merge 1 commit into
mainfrom
marc/pvc-serviceaccount-labels

Conversation

@marcleblanc2

@marcleblanc2 marcleblanc2 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem

  • A customer migrating from Kustomize requires the ability to add their own labels to parts of our product
  • The standalone PVCs hardcode their labels, and ServiceAccounts and RBAC objects have no label values

Solution

  • <serviceName>.storageLabels for the seven standalone PVCs: blobstore, codeInsightsDB, codeIntelDB, pgsql, prometheus, redisCache, redisStore
  • preciseCodeIntel.storageLabels and syntacticCodeIntel.storageLabels for the per-pod scratch PVC when storageType is pvc
  • Every PVC the sourcegraph chart creates now has a storageLabels value
    • On the StatefulSet PVCs, it applies to new claims only and can't change after install
  • <serviceName>.serviceAccount.labels for every ServiceAccount, and for the RBAC objects of frontend and prometheus
    • sourcegraph.labels and the standard Helm labels now also render on these objects too
  • The README now lists which values label each kind of PVC
    • PVCs that Kubernetes creates from a StatefulSet's volume claim template take only storageLabels, on purpose: Kubernetes rejects changes to those templates
  • Also fixes jaeger.serviceAccount.create: true, which failed to render when a label is applied

Upgrade impact

  • Only labels change, in place, on PVCs, ServiceAccounts, and the prometheus ClusterRole and ClusterRoleBinding

Tested

  • New tests/objectLabels_test.yaml covers every PVC, ServiceAccount, and RBAC template. The two code intel storage tests cover the scratch PVC
  • helm unittest (274 tests), helm lint, helm-docs, and kubeconform -strict pass
  • Rendered against main: only those object kinds differ, and no PVC spec changes
  • Rendered with storageType: pvc: the same output as before until storageLabels is set, then only the scratch PVC's labels differ

Amp threads

Changelog

  • Added <serviceName>.storageLabels and <serviceName>.serviceAccount.labels
  • sourcegraph.labels and the standard Helm labels are now on PVCs, ServiceAccounts, and the prometheus RBAC objects

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

@marcleblanc2
marcleblanc2 added this pull request to stack #1009 November 11, 2026 17:12
@marcleblanc2
marcleblanc2 force-pushed the marc/pvc-serviceaccount-labels branch from 3d258bf to aaffaa9 Compare November 11, 2026 17:45
@marcleblanc2 marcleblanc2 changed the title sourcegraph: add labels to PVCs, ServiceAccounts, and RBAC objects Render sourcegraph.labels on every object, and add storage and ServiceAccount labels Nov 11, 2026
@marcleblanc2
marcleblanc2 force-pushed the marc/pvc-serviceaccount-labels branch from 679ac13 to 7e6b950 Compare November 11, 2026 22:59
Base automatically changed from marc/selector-labels to main November 13, 2026 05:38
marcleblanc2 added a commit that referenced this pull request Nov 13, 2026
Prometheus does not reload a changed ConfigMap by itself, so an upgrade that
keeps the image tag swapped the RBAC resources while the pod kept running
the old scrape configuration.

The annotation, its test, and the changelog entry are the same as in #1008.
@marcleblanc2
marcleblanc2 force-pushed the marc/pvc-serviceaccount-labels branch from 6fd1fe2 to 756d760 Compare November 13, 2026 06:26
@marcleblanc2
marcleblanc2 marked this pull request as draft November 13, 2026 10:14
@marcleblanc2 marcleblanc2 changed the title Render sourcegraph.labels on every object, and add storage and ServiceAccount labels Apply sourcegraph.labels to all objects, and add storage and ServiceAccount labels Nov 18, 2026
@marcleblanc2
marcleblanc2 force-pushed the marc/pvc-serviceaccount-labels branch from 05bb302 to 71215b0 Compare November 18, 2026 18:09
@marcleblanc2 marcleblanc2 changed the title Apply sourcegraph.labels to all objects, and add storage and ServiceAccount labels feat/labels: Add labels to PVCs, ServiceAccounts, and RBAC objects Nov 18, 2026
@marcleblanc2
marcleblanc2 force-pushed the marc/pvc-serviceaccount-labels branch 2 times, most recently from d12bb2f to 42d6937 Compare November 18, 2026 20:08
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.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a1902b-ece9-725c-863d-3e2bba35ee1d
@marcleblanc2
marcleblanc2 force-pushed the marc/pvc-serviceaccount-labels branch from 42d6937 to e167670 Compare November 18, 2026 20:32

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant