You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e167670
Browse filesBrowse the repository at this point in the historyBrowse files
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.
Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a1902b-ece9-725c-863d-3e2bba35ee1d
Copy file name to clipboardExpand all lines: charts/sourcegraph/CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,8 @@ Use `**BREAKING**:` to denote a breaking change
9
9
## Unreleased
10
10
11
11
- 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.
12
+
- Added `storageLabels` on `blobstore`, `codeInsightsDB`, `codeIntelDB`, `pgsql`, `prometheus`, `redisCache`, and `redisStore` to label each component's PersistentVolumeClaim, and `<serviceName>.serviceAccount.labels` to label a component's ServiceAccount and, for `frontend` and `prometheus`, its Role, RoleBinding, ClusterRole, and ClusterRoleBinding. Also added `storageLabels` on `preciseCodeIntel` and `syntacticCodeIntel`, to label the per-pod `/tmp` scratch PersistentVolumeClaim when `storageType` is `pvc`; they default to empty, so no pod restarts. `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).
13
+
- 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.
12
14
- Added `sourcegraph.selectorLabelsOverride`, `<serviceName>.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).
13
15
- Fixed `frontend.command` and `migrator.command` rendering a list as a single element, e.g. `["sh", "-c", "<script>"]` became `[sh -c <script>]`, so the container failed to start. Both are now rendered as YAML lists and documented in `values.yaml`. A string holding a YAML list, the only form that worked before, still renders unchanged.
14
16
- Added `openTelemetry.gateway.command` to replace the `otel-collector` container's command, e.g. with a shell wrapper that exports an exporter API key read from a mounted file
- `<serviceName>.serviceAccount.labels`adds labels to one component's
115
+
ServiceAccount, and to the Role, RoleBinding, ClusterRole, and
116
+
ClusterRoleBinding of `frontend` and `prometheus`.
117
+
118
+
```yaml
119
+
sourcegraph:
120
+
labels:
121
+
example.com/project: sourcegraph
122
+
blobstore:
123
+
storageLabels:
124
+
example.com/service: blobstore
125
+
frontend:
126
+
serviceAccount:
127
+
labels:
128
+
example.com/service: frontend
129
+
```
130
+
104
131
Helm only takes over an existing object that has the
105
132
`app.kubernetes.io/managed-by: Helm` label and the `meta.helm.sh/release-name`
106
133
and `meta.helm.sh/release-namespace` annotations, or when installing with
107
134
`--take-ownership`(Helm 3.17 or later).
108
135
136
+
### PersistentVolumeClaim labels
137
+
138
+
The values that label a PersistentVolumeClaim depend on what creates it:
139
+
140
+
| Created by | Components | `<serviceName>.storageLabels` | `sourcegraph.labels` and the chart's standard labels |
141
+
| --- | --- | --- | --- |
142
+
| The chart, as its own object | `blobstore`, `codeInsightsDB`, `codeIntelDB`, `pgsql`, `prometheus`, `redisCache`, `redisStore` | Yes | Yes |
143
+
| Kubernetes, from a StatefulSet's volume claim template | `gitserver`, `grafana`, `indexedSearch`, `searcher` | Yes, at install only | No |
144
+
| Kubernetes, from a pod's ephemeral volume, when `storageType` is `pvc` | `preciseCodeIntel`, `syntacticCodeIntel` | Yes; changing them restarts the pods | No |
145
+
146
+
A StatefulSet's volume claim templates get neither `sourcegraph.labels` nor the
147
+
standard labels on purpose. Kubernetes rejects any change to them, so a chart
148
+
version that added these labels would fail the upgrade of existing releases,
149
+
and `helm.sh/chart` changes with every chart version.
150
+
151
+
Kubernetes copies a template's labels to a PersistentVolumeClaim only when it
152
+
creates the claim, and never updates a claim that exists. Helm does not manage
153
+
these claims either. Label an existing StatefulSet claim with
154
+
`kubectl label pvc`. An ephemeral volume's claim is deleted and created again
155
+
with its pod, so it always has the labels the chart renders.
156
+
109
157
## Configuration Options
110
158
111
159
Reference the below chart for all available configuration parameters.
@@ -129,6 +177,7 @@ In addition to the documented values, all services also support the following va
129
177
- `<serviceName>.extraSelectorLabels`- add labels to the service's workload selector, pod labels, and Service and PodDisruptionBudget selectors. See [Adopting existing workloads](#adopting-existing-workloads)
130
178
- `<serviceName>.serivceAccount.create`- create service account for service
131
179
- `<serviceName>.serviceAccount.annotations`- Annotations for the service-specific service account
180
+
- `<serviceName>.serviceAccount.labels`- Labels for the service-specific service account, and for the Role, RoleBinding, ClusterRole, and ClusterRoleBinding of `frontend` and `prometheus`, in addition to `sourcegraph.labels`
132
181
- `<serviceName>.image.repository`- override the global `sourcegraph.image.repository` (registry or prefix) for this service. Defaults to `sourcegraph.image.repository` when unset.
133
182
134
183
| Key | Type | Default | Description |
@@ -146,6 +195,7 @@ In addition to the documented values, all services also support the following va
146
195
| blobstore.serviceAccount.create | bool | `false` | Enable creation of ServiceAccount for `blobstore` |
147
196
| blobstore.serviceAccount.name | string | `""` | Name of the ServiceAccount to be created or an existing ServiceAccount |
148
197
| blobstore.storageAnnotations | object | `{}` | Optional annotations to add to the `blobstore` PVC |
198
+
| blobstore.storageLabels | object | `{}` | Optional labels to add to the `blobstore` PVC, in addition to `sourcegraph.labels` |
149
199
| blobstore.storageSize | string | `"100Gi"` | PVC Storage Request for `blobstore` data volume |
150
200
| blobstore.storageSubPath | string | `""` | Optional subPath for the `blobstore` primary data volume mount |
151
201
| cadvisor.containerSecurityContext | object | `{"privileged":true}` | Security context for the `cadvisor` container, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container) |
@@ -178,6 +228,7 @@ In addition to the documented values, all services also support the following va
178
228
| codeInsightsDB.serviceAccount.create | bool | `false` | Enable creation of ServiceAccount for `codeinsights-db` |
179
229
| codeInsightsDB.serviceAccount.name | string | `""` | Name of the ServiceAccount to be created or an existing ServiceAccount |
180
230
| codeInsightsDB.storageAnnotations | object | `{}` | Optional annotations to add to the `codeinsights-db` PVC |
231
+
| codeInsightsDB.storageLabels | object | `{}` | Optional labels to add to the `codeinsights-db` PVC, in addition to `sourcegraph.labels` |
181
232
| codeInsightsDB.storageSize | string | `"200Gi"` | PVC Storage Request for `codeinsights-db` data volume |
182
233
| codeInsightsDB.storageSubPath | string | `""` | Optional subPath for the `codeinsights-db` primary data volume mount |
183
234
| codeIntelDB.additionalConfig | string | `""` | Additional PostgreSQL configuration. This will override or extend our default configuration. Notes: This is expecting a multiline string. Learn more from our [recommended PostgreSQL configuration](https://docs.sourcegraph.com/admin/config/postgres-conf) and [PostgreSQL documentation](https://www.postgresql.org/docs/12/config-setting.html) |
@@ -200,6 +251,7 @@ In addition to the documented values, all services also support the following va
200
251
| codeIntelDB.serviceAccount.create | bool | `false` | Enable creation of ServiceAccount for `codeintel-db` |
201
252
| codeIntelDB.serviceAccount.name | string | `""` | Name of the ServiceAccount to be created or an existing ServiceAccount |
202
253
| codeIntelDB.storageAnnotations | object | `{}` | Optional annotations to add to the `codeintel-db` PVC |
254
+
| codeIntelDB.storageLabels | object | `{}` | Optional labels to add to the `codeintel-db` PVC, in addition to `sourcegraph.labels` |
203
255
| codeIntelDB.storageSize | string | `"200Gi"` | PVC Storage Request for `codeintel-db` data volume |
204
256
| codeIntelDB.storageSubPath | string | `""` | Optional subPath for the `codeintel-db` primary data volume mount |
205
257
| extraResources | list | `[]` | Additional resources to include in the rendered manifest. Templates are supported. |
@@ -374,6 +426,7 @@ In addition to the documented values, all services also support the following va
374
426
| pgsql.serviceAccount.create | bool | `false` | Enable creation of ServiceAccount for `pgsql` |
375
427
| pgsql.serviceAccount.name | string | `""` | Name of the ServiceAccount to be created or an existing ServiceAccount |
376
428
| pgsql.storageAnnotations | object | `{}` | Optional annotations to add to the `pgsql` PVC |
429
+
| pgsql.storageLabels | object | `{}` | Optional labels to add to the `pgsql` PVC, in addition to `sourcegraph.labels` |
377
430
| pgsql.storageSize | string | `"200Gi"` | PVC Storage Request for `pgsql` data volume |
378
431
| pgsql.storageSubPath | string | `""` | Optional subPath for the `pgsql` primary data volume mount |
379
432
| postgresExporter.image.defaultTag | string | `<appVersion>@sha256:<digest>`, pinned by each release | Docker image tag for the `pgsql-exporter` image |
@@ -391,6 +444,7 @@ In addition to the documented values, all services also support the following va
391
444
| preciseCodeIntel.serviceAccount.create | bool | `false` | Enable creation of ServiceAccount for `precise-code-intel-worker` |
392
445
| preciseCodeIntel.serviceAccount.name | string | `""` | Name of the ServiceAccount to be created or an existing ServiceAccount |
393
446
| preciseCodeIntel.storageClassName | string | `""` | StorageClass for the `/tmp` scratch PVC when storageType is `pvc`. Empty uses the cluster default class. The claim is per-pod and discarded with the pod, so this class must use `reclaimPolicy: Delete`; `storageClass` is `Retain` for stateful data and is not used here. |
447
+
| preciseCodeIntel.storageLabels | object | `{}` | Labels to add to the `/tmp` scratch PVC when storageType is `pvc`. Changing them restarts the pods. See [PersistentVolumeClaim labels](#persistentvolumeclaim-labels) |
394
448
| preciseCodeIntel.storageSize | string | `""` | Size of the `/tmp` scratch volume. Required when storageType is `pvc`. When storageType is `emptyDir` this sets `sizeLimit` (optional, leave empty for unlimited). |
395
449
| preciseCodeIntel.storageType | string | `"emptyDir"` | Backing store for the `/tmp` scratch volume, used for large SCIP upload processing. One of: emptyDir, pvc. emptyDir: node ephemeral storage, i.e. the node boot disk. pvc: per-pod PVC, discarded with the pod. The pod `fsGroup` defaults to the container `runAsGroup` so the non-root worker can write to the volume; set `podSecurityContext.fsGroup` to override it. |
396
450
| priorityClasses | list | `[]` | Additional priorityClasses minimize re-scheduling downtime for StatefulSets. Each StatefulSets might use different priority class. learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#priorityclass) Sample class definition: - name: gitserver-class value: 100 preemptionPolicy: Never description: "gitserver priority class" |
@@ -407,6 +461,7 @@ In addition to the documented values, all services also support the following va
| prometheus.serviceAccount.name | string | `"prometheus"` | Name of the ServiceAccount to be created or an existing ServiceAccount |
409
463
| prometheus.storageAnnotations | object | `{}` | Optional annotations to add to the `prometheus` PVC |
464
+
| prometheus.storageLabels | object | `{}` | Optional labels to add to the `prometheus` PVC, in addition to `sourcegraph.labels` |
410
465
| prometheus.storageSize | string | `"200Gi"` | PVC Storage Request for `prometheus` data volume |
411
466
| prometheus.storageSubPath | string | `""` | Optional subPath for the `prometheus` primary data volume mount |
412
467
| redisCache.config.additionalConfig | string | `""` | Additional raw redis directives appended to the vendored `redis-cache` config. Notes: This is expecting a multiline string. It renders into a ConfigMap in plaintext, so do not put secrets such as `requirepass` here or in `existingConfig` (also a ConfigMap). For secrets, set `config.enabled: false` and mount a Secret using `extraVolumeMounts`. |
@@ -428,6 +483,7 @@ In addition to the documented values, all services also support the following va
428
483
| redisCache.serviceAccount.create | bool | `false` | Enable creation of ServiceAccount for `redis-cache` |
429
484
| redisCache.serviceAccount.name | string | `""` | Name of the ServiceAccount to be created or an existing ServiceAccount |
430
485
| redisCache.storageAnnotations | object | `{}` | Optional annotations to add to the `redis-cache` PVC |
486
+
| redisCache.storageLabels | object | `{}` | Optional labels to add to the `redis-cache` PVC, in addition to `sourcegraph.labels` |
431
487
| redisCache.storageSize | string | `"100Gi"` | PVC Storage Request for `redis-cache` data volume |
432
488
| redisCache.storageSubPath | string | `""` | Optional subPath for the `redis-cache` primary data volume mount |
433
489
| redisExporter.containerSecurityContext | object | `{"allowPrivilegeEscalation":false,"readOnlyRootFilesystem":true,"runAsGroup":1000,"runAsUser":999}` | Security context for the `redis-exporter` sidecar container, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container) |
@@ -453,6 +509,7 @@ In addition to the documented values, all services also support the following va
453
509
| redisStore.serviceAccount.create | bool | `false` | Enable creation of ServiceAccount for `redis-store` |
454
510
| redisStore.serviceAccount.name | string | `""` | Name of the ServiceAccount to be created or an existing ServiceAccount |
455
511
| redisStore.storageAnnotations | object | `{}` | Optional annotations to add to the `redis-store` PVC |
512
+
| redisStore.storageLabels | object | `{}` | Optional labels to add to the `redis-store` PVC, in addition to `sourcegraph.labels` |
456
513
| redisStore.storageSize | string | `"100Gi"` | PVC Storage Request for `redis-store` data volume |
457
514
| redisStore.storageSubPath | string | `""` | Optional subPath for the `redis-store` primary data volume mount |
458
515
| searcher.autoCacheSize | bool | `false` | When enabled, omit the `SEARCHER_CACHE_SIZE_MB` and `SYMBOLS_CACHE_SIZE_MB` env vars so `searcher` auto-sizes its cache to ~45% of the live cache volume. This tracks PVC expansion automatically, whereas the hardcoded env vars are frozen to the initial `storageSize` and do not follow later disk growth. |
@@ -512,6 +569,7 @@ In addition to the documented values, all services also support the following va
512
569
| syntacticCodeIntel.serviceAccount.create | bool | `false` | Enable creation of ServiceAccount for `syntactic-code-intel-worker` |
513
570
| syntacticCodeIntel.serviceAccount.name | string | `""` | Name of the ServiceAccount to be created or an existing ServiceAccount |
514
571
| syntacticCodeIntel.storageClassName | string | `""` | StorageClass for the `/tmp` scratch PVC when storageType is `pvc`. Empty uses the cluster default class. The claim is per-pod and discarded with the pod, so this class must use `reclaimPolicy: Delete`; `storageClass` is `Retain` for stateful data and is not used here. |
572
+
| syntacticCodeIntel.storageLabels | object | `{}` | Labels to add to the `/tmp` scratch PVC when storageType is `pvc`. Changing them restarts the pods. See [PersistentVolumeClaim labels](#persistentvolumeclaim-labels) |
515
573
| syntacticCodeIntel.storageSize | string | `""` | Size of the `/tmp` scratch volume. Required when storageType is `pvc`. When storageType is `emptyDir` this sets `sizeLimit` (optional, leave empty for unlimited). |
516
574
| syntacticCodeIntel.storageType | string | `"emptyDir"` | Backing store for the `/tmp` scratch volume, used for indexing. One of: emptyDir, pvc. emptyDir: node ephemeral storage, i.e. the node boot disk. pvc: per-pod PVC, discarded with the pod. The pod `fsGroup` defaults to the container `runAsGroup` so the non-root worker can write to the volume; set `podSecurityContext.fsGroup` to override it. |
517
575
| syntectServer.containerSecurityContext | object | `{"allowPrivilegeEscalation":false,"readOnlyRootFilesystem":true,"runAsGroup":101,"runAsUser":100}` | Security context for the `syntect-server` container, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container) |
0 commit comments