Skip to content

Create global container and pod security context configs - #818

Open
marcleblanc2 wants to merge 1 commit into
mainfrom
marc/global-security-context
Open

marcleblanc2 wants to merge 1 commit into
mainfrom
marc/global-security-context

Conversation

@marcleblanc2

@marcleblanc2 marcleblanc2 commented Feb 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem:

  • When customers need to modify containerSecurityContext and / or podSecurityContext, they generally need to modify the same on all containers or all pods
  • For example, customers running in RedHat OpenShift must set runAsUser, runAsGroup, and fsGroup on all containers / pods to the same UID / GID assigned to their Kubernetes namespace (OpenShift Project)
  • Specific customer examples provided in Slack thread
  • This creates a bloated and hard-to-maintain override file, with scads of duplicate lines, or relies on using YAML hacks

Solution:

  • Create global configs, .Values.sourcegraph.containerSecurityContext and .Values.sourcegraph.podSecurityContext, so customers can set the global configs in one place, and if set, override our defaults
  • Renamed our default containerSecurityContext and podSecurityContext to defaultContainerSecurityContext and defaultPodSecurityContext, and created empty containerSecurityContext and podSecurityContext keys, so customers who already define overrides for these will continue as-is, without change, and this allows customers to set both the global configs to override our defaults, and override specific configs for specific pods / containers.

Linear issue FEIE-301: Usability: Create instance-wide config for default podSecurityContext and containerSecurityContext

Checklist

Test plan

  • helm unittest and helm lint pass, for all 4 charts

Tested with helm template commands and compared diffs, using:

  • Default values.yaml
  • override.yaml files from 3 different customers

@marcleblanc2
marcleblanc2 requested a review from a team February 4, 2026 09:07
@michaellzc
michaellzc force-pushed the marc/global-security-context branch from 26ba364 to 7a23a3a Compare February 18, 2026 00:52
@marcleblanc2
marcleblanc2 force-pushed the marc/global-security-context branch from 7a23a3a to 8d667bc Compare October 30, 2026 22:00
@github-actions

Copy link
Copy Markdown

Add .Values.sourcegraph.containerSecurityContext and
.Values.sourcegraph.podSecurityContext so customers (e.g. OpenShift) can set
runAsUser / runAsGroup / fsGroup once for every container and pod.

Rename each component's shipped defaults to defaultContainerSecurityContext /
defaultPodSecurityContext and add empty containerSecurityContext /
podSecurityContext override keys. Templates render the 3-tier merge
(component default -> global -> component override) through shared helpers
in templates/_helpers/_securityContext.tpl, copied into all four charts.

- precise-code-intel-worker derives fsGroup from the merged container runAsGroup
- cadvisor gates /dev/kmsg on the merged privileged value
- k8s executor keeps the deprecated executor.securityContext pod fallback
- dind executor keeps dind.gVisor.securityContext as a full replacement
- otel-agent and otel-collector pods gain pod security context keys

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a18eb0-b6fb-7675-8f04-2fc05d2fe567
@marcleblanc2
marcleblanc2 force-pushed the marc/global-security-context branch from 8d667bc to 4e71e8e Compare October 30, 2026 22:46

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