Skip to content

executor/k8s: Restore replicas, add Kubernetes client limits and job ephemeral storage - #1029

Draft
marcleblanc2 wants to merge 3 commits into
mainfrom
marc/executor-k8s-scaling
Draft

marcleblanc2 wants to merge 3 commits into
mainfrom
marc/executor-k8s-scaling

Conversation

@marcleblanc2

@marcleblanc2 marcleblanc2 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The Kubernetes-native executor chart hardcodes replicas: 1, with a comment saying executor pods pin job pods to their own node and contend for a ReadWriteOnce PVC. Neither is true:

Executors dequeue with SKIP LOCKED, have unique names, and give each job its own pod and workspace volume, so several executor pods can serve the same queues.

Solution

  • executor.replicas, default 1
  • executor.kubernetesClient.qps and burst, which set EXECUTOR_KUBERNETES_CLIENT_QPS and _BURST, and render only when set, so the executor's defaults apply
  • executor.kubernetesJob.resources.requests.ephemeralStorage and limits.ephemeralStorage, which render only when set
  • executor.kubernetesJob.podSecurityContext and containerSecurityContext, as YAML, which set KUBERNETES_EXECUTOR_POD_SECURITY_CONTEXT and KUBERNETES_EXECUTOR_CONTAINER_SECURITY_CONTEXT, so job pods can run in Pod Security Admission restricted namespaces. The executor has read both since 7.3; the chart had no way to set them except extraEnv.
  • executor.kubernetesJob.node.tolerations, requiredAffinityMatchExpressions, requiredAffinityMatchFields, pod.affinity, and pod.antiAffinity now accept YAML lists, rendered with toJson. Before, the ConfigMap wrapped these strings in double quotes without escaping, so plain JSON failed to render (did not find expected key) and customers had to backslash-escape every quote. Escaped strings still render the same.
  • CHANGELOG, README (helm-docs), and unit tests

Older executor images ignore the new environment variables.

Testing

  • helm unittest charts/sourcegraph-executor/k8s (12 passed)
  • Rendered YAML-list and security-context values, then decoded each ConfigMap value into the executor's Kubernetes types ([]corev1.Toleration, []corev1.NodeSelectorRequirement, []corev1.PodAffinityTerm, corev1.PodSecurityContext, corev1.SecurityContext) with unknown fields disallowed: all parse. An old escaped-string override renders and parses unchanged.
  • EKS test: see the comment below once it runs

Linked PRs

  • sourcegraph/sourcegraph#19649: Kubernetes API client QPS and burst
  • sourcegraph/sourcegraph#19650: job pod ephemeral storage, Job TTL, dead PVC config
  • sourcegraph/sourcegraph#19651: stream job container logs
  • sourcegraph/sourcegraph#19652: workspace files through the job Secret
  • sourcegraph/sourcegraph#19653: batches dequeue without ranking the queue
  • sourcegraph/sourcegraph#19654: docs
  • executors/k8s: Remove the unused /data PVC and the job pod affinity deploy-sourcegraph-k8s#519: Kustomize component PVC and affinity

Amp threads

…ephemeral storage

The chart hardcoded replicas: 1 with a comment saying executor pods
pin job pods to their node and contend for a ReadWriteOnce PVC. Neither
is true: the chart never sets EXECUTOR_KUBERNETES_NODE_NAME by default,
and #911 removed that PVC. Executors dequeue with SKIP LOCKED, have
unique names, and give each job its own pod and workspace volume, so
several executor pods can serve the same queues.

- executor.replicas, default 1
- executor.kubernetesClient.qps / burst, rendered only when set, for
  EXECUTOR_KUBERNETES_CLIENT_QPS / BURST
- executor.kubernetesJob.resources.{requests,limits}.ephemeralStorage,
  rendered only when set

Amp-Thread-ID: https://ampcode.com/threads/T-01a20ade-0ba8-7364-b673-ac2197c102c9
Co-authored-by: Amp <amp@ampcode.com>
@github-actions

Copy link
Copy Markdown

marcleblanc2 and others added 2 commits November 24, 2026 15:56
Tolerations, node affinity, and pod affinity values now accept YAML
lists, rendered as JSON. Escaped JSON strings still work.

Add kubernetesJob.podSecurityContext and containerSecurityContext,
which set KUBERNETES_EXECUTOR_POD_SECURITY_CONTEXT and
KUBERNETES_EXECUTOR_CONTAINER_SECURITY_CONTEXT, so job pods can run
in Pod Security Admission restricted namespaces.

Amp-Thread-ID: https://ampcode.com/threads/T-01a20ade-0ba8-7364-b673-ac2197c102c9
Co-authored-by: Amp <amp@ampcode.com>

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