Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
71c148a
Render sourcegraph.labels on every object in all four charts
marcleblanc2 Nov 11, 2026
d31f087
sourcegraph: render redisStore.serviceAccount.annotations
marcleblanc2 Nov 11, 2026
4bff4dd
Add deploy, component, and per-component labels to every object
marcleblanc2 Nov 11, 2026
56deff2
Keep sourcegraph.labels off metrics and label the otel-collector Serv…
marcleblanc2 Nov 11, 2026
ccc11d4
otel-collector: serve the collector's own metrics on all interfaces
marcleblanc2 Nov 11, 2026
967bb94
otel-collector: document what a replacement command needs for its met…
marcleblanc2 Nov 11, 2026
67af08e
sourcegraph: restart prometheus when its configuration changes
marcleblanc2 Nov 11, 2026
597b7ab
Add the common labels to pods and keep them off all scraped metrics
marcleblanc2 Nov 11, 2026
a29252e
otel-collector: pass the metrics setting as an argument
marcleblanc2 Nov 11, 2026
d8092fe
otel-collector: restart when its configuration changes
marcleblanc2 Nov 11, 2026
aa51a4c
Keep the chart version labels off pod templates
marcleblanc2 Nov 11, 2026
2b68a9e
Move the label helpers to _helpers/_labels.tpl in all four charts
marcleblanc2 Nov 13, 2026
d70f249
jaeger: keep the release name on the pod's instance label
marcleblanc2 Nov 18, 2026
80551f7
otel-collector: say how each shell wrapper form passes the metrics ar…
marcleblanc2 Nov 18, 2026
5c08a48
executor/dind: add executor.storage.labels for the per-pod PVC
marcleblanc2 Nov 18, 2026
34b6612
executor/dind: add privateDockerRegistry.storageLabels and document P…
marcleblanc2 Nov 18, 2026
591d864
Label the per-pod PVCs of ephemeral volumes like every other PVC
marcleblanc2 Nov 18, 2026
5dffc4a
Move the helpers this branch changes out of _helpers.tpl
marcleblanc2 Nov 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions charts/sourcegraph-executor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
<!-- START CHANGELOG -->
## Unreleased

- Added `executor.storage.labels` to the `sourcegraph-executor-dind` chart to label the per-pod PersistentVolumeClaim that is created when `executor.storage.type` is `ephemeral`. That claim now also gets `sourcegraph.labels`, the chart's standard labels, `deploy`, and `app.kubernetes.io/component`, so with `executor.storage.type: ephemeral` the executor pods restart whenever the chart version changes. Changing `executor.storage.labels` restarts them too.
- Added `privateDockerRegistry.storageLabels` to the `sourcegraph-executor-dind` chart to label the `cache` volume claim template of the `private-docker-registry` StatefulSet. It defaults to empty, so existing releases render the same template. Set it on the first install and never change it on an installed release: Kubernetes does not allow changing a StatefulSet's volume claim templates. See [PersistentVolumeClaim labels](dind/README.md#persistentvolumeclaim-labels).
- Every object the charts create now has the `deploy` and `app.kubernetes.io/component` labels: the `sourcegraph-executor-k8s` Secret did not have them. `executor.labels` is now also rendered on the `sourcegraph-executor-k8s` ConfigMap, Secret, ServiceAccount, Role, and RoleBinding, and on the `sourcegraph-executor-dind` `docker-config` ConfigMap, not only on the Deployment. Added `privateDockerRegistry.serviceLabels` to the `sourcegraph-executor-dind` chart to label the `private-docker-registry` Service.
- `sourcegraph.labels` and the charts' standard labels (`helm.sh/chart`, `app.kubernetes.io/name`, `app.kubernetes.io/instance`, `app.kubernetes.io/version`, `app.kubernetes.io/managed-by`) are now rendered on every object the charts create. The `sourcegraph-executor-k8s` chart rendered them on none of its objects (ConfigMap, Deployment, Role, RoleBinding, Secret, Service, ServiceAccount), and the `sourcegraph-executor-dind` chart did not render them on the `docker-config` ConfigMap and the `private-docker-registry` Service. Pods get them too, except `helm.sh/chart` and `app.kubernetes.io/version`, which change with every chart version and would restart every pod on every upgrade. The `private-docker-registry` pod gains `app.kubernetes.io/component`. Existing releases gain these labels on upgrade. No object is recreated. Every pod restarts once, on this upgrade.

## 8.0.0

* Added a `network-policy` example to the `sourcegraph-executor-k8s` and `sourcegraph-executor-dind` charts, with `CiliumNetworkPolicy` resources which limit Executor and job pods to the frontend API.
Expand Down
18 changes: 18 additions & 0 deletions charts/sourcegraph-executor/dind/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@ helm repo add sourcegraph https://helm.sourcegraph.com/release

Manifests rendered using the `helm template` command can be used for direct deployment using `kubectl`.

## PersistentVolumeClaim labels

Kubernetes creates both of this chart's PersistentVolumeClaims from a template, so Helm does not manage them:

| PersistentVolumeClaim | Created from | Labels |
| --- | --- | --- |
| The registry's `cache` | The `private-docker-registry` StatefulSet's volume claim template | `deploy`, `app.kubernetes.io/component`, and `privateDockerRegistry.storageLabels` |
| The executor's scratch volume, when `executor.storage.type` is `ephemeral` | The executor pod's ephemeral volume | `sourcegraph.labels`, the chart's standard labels, `deploy`, `app.kubernetes.io/component`, and `executor.storage.labels` |

The registry's claim gets neither `sourcegraph.labels` nor the chart's standard labels: a chart version that added them would fail the upgrade of existing releases.

Set `privateDockerRegistry.storageLabels` on the first install and never change it on an installed release. Kubernetes rejects any change to a StatefulSet's volume claim templates, so the upgrade fails. Kubernetes also never updates the labels of a claim that exists: label an existing one with `kubectl label pvc`.

The scratch volume's claim is deleted and created again with its pod, so it always has the labels the chart renders. Its labels are part of the pod template: changing one restarts the executor pods, and so does every change of the chart version, which is in `helm.sh/chart`.

## Configuration Options

Reference the table below for available configuration parameters and consult [executor] documentation.
Expand Down Expand Up @@ -83,13 +98,16 @@ In addition to the documented values, the `executor` and `private-docker-registr
| executor.replicaCount | int | `1` | |
| executor.resources | object | `{}` | Resource requests and limits for the executor container. Each queue can override this with its own resources field. |
| executor.storage.class | string | `""` | StorageClass for the ephemeral volume. Only used when type is ephemeral. Defaults to the cluster default StorageClass when empty. |
| executor.storage.labels | object | `{}` | Optional labels to add to the ephemeral volume's PVC, in addition to `sourcegraph.labels`. Only used when type is ephemeral. Changing them restarts the executor pods. See [PersistentVolumeClaim labels](#persistentvolumeclaim-labels) |
| executor.storage.size | string | `""` | Size of the scratch volume. emptyDir: sets sizeLimit (optional, leave empty for unlimited). ephemeral: sets the PVC storage request (required). |
| executor.storage.type | string | `"emptyDir"` | Type of scratch volume for job workspaces. One of: emptyDir, ephemeral. emptyDir: plain emptyDir, no storage class required. ephemeral: per-pod PVC via the cluster default storage class; size is required. |
| privateDockerRegistry.enabled | bool | `true` | Whether to deploy the private registry. Only one registry is needed when deploying multiple executors. More information: https://sourcegraph.com/docs/self-hosted/executors/deploy-executors#using-private-registries |
| privateDockerRegistry.env | object | `{"REGISTRY_PROXY_REMOTEURL":{"value":"https://registry-1.docker.io"}}` | Extra environment variables to set on the registry container. Registry can be configured with environment variables using the pattern REGISTRY_<SECTION>_<KEY> (uppercase). Full reference: https://distribution.github.io/distribution/about/configuration To proxy an internal private registry with credentials, override REGISTRY_PROXY_REMOTEURL and supply REGISTRY_PROXY_USERNAME / REGISTRY_PROXY_PASSWORD, e.g.: env: REGISTRY_PROXY_REMOTEURL: value: https://my-internal-registry.example.com REGISTRY_PROXY_USERNAME: value: myuser REGISTRY_PROXY_PASSWORD: valueFrom: secretKeyRef: name: registry-proxy-credentials key: password |
| privateDockerRegistry.image.registry | string | `"index.docker.io"` | |
| privateDockerRegistry.image.repository | string | `"registry"` | |
| privateDockerRegistry.image.tag | int | `3` | |
| privateDockerRegistry.serviceLabels | object | `{}` | Add extra labels to the `private-docker-registry` Service |
| privateDockerRegistry.storageLabels | object | `{}` | Labels to add to the `cache` volume claim template of the `private-docker-registry` StatefulSet. Kubernetes does not allow changing them on an installed StatefulSet. See [PersistentVolumeClaim labels](#persistentvolumeclaim-labels) |
| privateDockerRegistry.storageSize | string | `"10Gi"` | |
| queues | list | `[]` | Optional list of queues to deploy as standalone Deployments. When set, the single executor Deployment is not rendered. Each entry supports: name (required) — used as the deployment name suffix (executor-<name>) queueName — sets EXECUTOR_QUEUE_NAME; defaults to name if omitted queueNames — sets EXECUTOR_QUEUE_NAMES (comma-joined); takes precedence over queueName when set replicaCount, resources, env (merged with executor.env, queue overrides) |
| sourcegraph.affinity | object | `{}` | Affinity, learn more from the [Kubernetes documentation](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity) |
Expand Down
15 changes: 15 additions & 0 deletions charts/sourcegraph-executor/dind/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@ helm repo add sourcegraph https://helm.sourcegraph.com/release

Manifests rendered using the `helm template` command can be used for direct deployment using `kubectl`.

## PersistentVolumeClaim labels

Kubernetes creates both of this chart's PersistentVolumeClaims from a template, so Helm does not manage them:

| PersistentVolumeClaim | Created from | Labels |
| --- | --- | --- |
| The registry's `cache` | The `private-docker-registry` StatefulSet's volume claim template | `deploy`, `app.kubernetes.io/component`, and `privateDockerRegistry.storageLabels` |
| The executor's scratch volume, when `executor.storage.type` is `ephemeral` | The executor pod's ephemeral volume | `sourcegraph.labels`, the chart's standard labels, `deploy`, `app.kubernetes.io/component`, and `executor.storage.labels` |

The registry's claim gets neither `sourcegraph.labels` nor the chart's standard labels: a chart version that added them would fail the upgrade of existing releases.

Set `privateDockerRegistry.storageLabels` on the first install and never change it on an installed release. Kubernetes rejects any change to a StatefulSet's volume claim templates, so the upgrade fails. Kubernetes also never updates the labels of a claim that exists: label an existing one with `kubectl label pvc`.

The scratch volume's claim is deleted and created again with its pod, so it always has the labels the chart renders. Its labels are part of the pod template: changing one restarts the executor pods, and so does every change of the chart version, which is in `helm.sh/chart`.

## Configuration Options

Reference the table below for available configuration parameters and consult [executor] documentation.
Expand Down
267 changes: 0 additions & 267 deletions charts/sourcegraph-executor/dind/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,6 @@ Create chart name and version as used by the chart label.
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "sourcegraph.labels" -}}
helm.sh/chart: {{ include "sourcegraph.chart" . }}
{{ include "sourcegraph.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- if .Values.sourcegraph.labels }}
{{ toYaml .Values.sourcegraph.labels }}
{{- end }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "sourcegraph.selectorLabels" -}}
app.kubernetes.io/name: {{ include "sourcegraph.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
Expand Down Expand Up @@ -107,13 +84,6 @@ executor-{{join "-" .Values.executor.queueNames }}
{{- end }}
{{- end }}

{{- define "executor.labels" -}}
app: {{ include "executor.name" . }}
deploy: sourcegraph
sourcegraph-resource-requires: no-cluster-admin
app.kubernetes.io/component: executor
{{- end}}

{{- define "dind.daemonConfig" -}}
{{- $config := .Values.dind.daemonConfig | deepCopy }}
{{- if .Values.dind.gVisor.enabled }}
Expand All @@ -122,243 +92,6 @@ app.kubernetes.io/component: executor
{{- $config | toPrettyJson }}
{{- end }}

{{/*
Render a single executor Deployment.
Usage: include "executor.deployment" (dict "root" $ "name" "executor-foo" "queueName" "foo" "queueNames" (list) "replicaCount" 1 "resources" $res "env" $env)
*/}}
{{- define "executor.deployment" -}}
{{- $r := .root -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .name }}
annotations:
description: Runs sourcegraph executors
kubectl.kubernetes.io/default-container: executor
labels:
{{- include "sourcegraph.labels" $r | nindent 4 }}
{{- if $r.Values.executor.labels }}
{{- toYaml $r.Values.executor.labels | nindent 4 }}
{{- end }}
app: {{ .name }}
deploy: sourcegraph
sourcegraph-resource-requires: no-cluster-admin
app.kubernetes.io/component: executor
spec:
selector:
matchLabels:
{{- include "sourcegraph.selectorLabels" $r | nindent 6 }}
app: {{ .name }}
minReadySeconds: 10
replicas: {{ .replicaCount }}
revisionHistoryLimit: 10
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: executor
checksum/docker-config: {{ include "dind.daemonConfig" $r | sha256sum }}
{{- if $r.Values.sourcegraph.podAnnotations }}
{{- toYaml $r.Values.sourcegraph.podAnnotations | nindent 8 }}
{{- end }}
{{- if $r.Values.executor.podAnnotations }}
{{- toYaml $r.Values.executor.podAnnotations | nindent 8 }}
{{- end }}
labels:
{{- include "sourcegraph.selectorLabels" $r | nindent 8 }}
{{- if $r.Values.sourcegraph.podLabels }}
{{- toYaml $r.Values.sourcegraph.podLabels | nindent 8 }}
{{- end }}
{{- if $r.Values.executor.podLabels }}
{{- toYaml $r.Values.executor.podLabels | nindent 8 }}
{{- end }}
app: {{ .name }}
deploy: sourcegraph
sourcegraph-resource-requires: no-cluster-admin
app.kubernetes.io/component: executor
spec:
{{- with $r.Values.executor.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: executor
image: {{ include "sourcegraph.image" (list $r "executor") }}
imagePullPolicy: {{ $r.Values.sourcegraph.image.pullPolicy }}
livenessProbe:
httpGet:
path: /healthz
port: http-debug
scheme: HTTP
initialDelaySeconds: 60
timeoutSeconds: 5
readinessProbe:
httpGet:
path: /healthz
port: http-debug
scheme: HTTP
periodSeconds: 5
timeoutSeconds: 5
ports:
- name: http-debug
containerPort: 8080
terminationMessagePolicy: FallbackToLogsOnError
env:
- name: EXECUTOR_FRONTEND_URL
value: {{ $r.Values.executor.frontendUrl | quote }}
- name: EXECUTOR_FRONTEND_PASSWORD
{{- if $r.Values.executor.frontendExistingSecret }}
valueFrom:
secretKeyRef:
name: {{ $r.Values.executor.frontendExistingSecret }}
key: EXECUTOR_FRONTEND_PASSWORD
{{- else }}
value: {{ $r.Values.executor.frontendPassword | quote }}
{{- end }}
{{- if .queueNames }}
- name: EXECUTOR_QUEUE_NAMES
value: {{ join "," .queueNames | quote }}
{{- else }}
- name: EXECUTOR_QUEUE_NAME
value: {{ .queueName | quote }}
{{- end }}
- name: SRC_LOG_LEVEL
value: {{ $r.Values.executor.log.level | quote }}
- name: SRC_LOG_FORMAT
value: {{ $r.Values.executor.log.format | quote }}
- name: EXECUTOR_MAXIMUM_RUNTIME_PER_JOB
value: {{ $r.Values.executor.maximumRuntimePerJob | quote }}
- name: EXECUTOR_USE_FIRECRACKER
value: "false"
- name: EXECUTOR_USE_KUBERNETES
value: "false"
- name: EXECUTOR_HEALTH_SERVER_ADDR
value: ":8080"
- name: EXECUTOR_JOB_NUM_CPUS
value: "0"
- name: EXECUTOR_JOB_MEMORY
value: "0"
- name: DOCKER_HOST
value: tcp://localhost:2375
- name: TMPDIR
value: /scratch
{{- range $name, $item := .env }}
- name: {{ $name }}
{{- $item | toYaml | nindent 14 }}
{{- end }}
volumeMounts:
- mountPath: /scratch
name: executor-scratch
{{- with .resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
- name: dind
image: "{{ $r.Values.dind.image.registry }}/{{ $r.Values.dind.image.repository }}:{{ $r.Values.dind.image.tag }}"
imagePullPolicy: {{ $r.Values.sourcegraph.image.pullPolicy }}
securityContext:
{{- if $r.Values.dind.gVisor.enabled }}
{{- toYaml $r.Values.dind.gVisor.securityContext | nindent 12 }}
{{- else }}
privileged: true
{{- end }}
command:
{{- if $r.Values.dind.gVisor.enabled }}
{{- toYaml $r.Values.dind.gVisor.command | nindent 12 }}
{{- else }}
{{- toYaml $r.Values.dind.command | nindent 12 }}
{{- end }}
livenessProbe:
exec:
command:
- wget
- -qO-
- http://127.0.0.1:2375/_ping
initialDelaySeconds: 15
periodSeconds: 5
failureThreshold: 5
readinessProbe:
exec:
command:
- wget
- -qO-
- http://127.0.0.1:2375/_ping
initialDelaySeconds: 20
periodSeconds: 5
failureThreshold: 5
env:
- name: POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
ports:
- containerPort: 2375
protocol: TCP
volumeMounts:
- mountPath: /scratch
name: executor-scratch
- mountPath: /etc/docker/daemon.json
subPath: daemon.json
name: docker-config
{{- if $r.Values.dind.gVisor.enabled }}
- mountPath: /var/lib/docker
name: docker
{{- end }}
enableServiceLinks: false
{{- if $r.Values.dind.gVisor.enabled }}
runtimeClassName: gvisor
{{- end }}
{{- with $r.Values.sourcegraph.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $r.Values.sourcegraph.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with include "sourcegraph.priorityClassName" (list $r "executor") | trim }}{{ . | nindent 6 }}{{- end }}
{{- with $r.Values.sourcegraph.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $r.Values.sourcegraph.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: executor-scratch
{{- if eq $r.Values.executor.storage.type "ephemeral" }}
ephemeral:
volumeClaimTemplate:
spec:
accessModes: ["ReadWriteOnce"]
{{- if $r.Values.executor.storage.class }}
storageClassName: {{ $r.Values.executor.storage.class }}
{{- end }}
resources:
requests:
storage: {{ required "executor.storage.size is required when storage.type is ephemeral" $r.Values.executor.storage.size }}
{{- else }}
emptyDir:
{{- if $r.Values.executor.storage.size }}
sizeLimit: {{ $r.Values.executor.storage.size }}
{{- end }}
{{- end }}
- name: docker-config
configMap:
defaultMode: 420
name: docker-config
{{- if $r.Values.dind.gVisor.enabled }}
- name: docker
emptyDir: {}
{{- end }}
{{- end }}

{{/*
Validate that an env dict does not contain managed environment variable names.
Usage: include "executor.validateEnv" (list $envDict "label")
Expand Down
Loading
Loading