Repository navigation
Create global container and pod security context configs - #818
Draft
marcleblanc2 wants to merge 2 commits into
Draft
marcleblanc2 wants to merge 2 commits into
marcleblanc2 wants to merge 2 commits into
Conversation
michaellzc
force-pushed
the
marc/global-security-context
branch
from
February 18, 2026 00:52
26ba364 to
7a23a3a
Compare
marcleblanc2
force-pushed
the
marc/global-security-context
branch
from
October 30, 2026 22:00
7a23a3a to
8d667bc
Compare
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
force-pushed
the
marc/global-security-context
branch
from
October 30, 2026 22:46
8d667bc to
4e71e8e
Compare
#1016 deletes the executor's http-debug port 6060 and the executor-<queueName> Service in front of it: the executor has not served that port since Sourcegraph 4.1. Making the same deletions here keeps this PR and #1016 from conflicting in those files. Amp-Thread-ID: https://ampcode.com/threads/T-01a1d269-2788-7075-b66b-b87e3087047d Co-authored-by: Amp <amp@ampcode.com>
marcleblanc2
marked this pull request as draft
November 13, 2026 10:02
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Open issues
Found in review on 2026-11-13 (review thread). This PR is a draft until the first four are settled.
seccompProfile.type: RuntimeDefaultandgitserver.podSecurityContext.seccompProfile.type: Unconfined, six workloads renderUnconfined: gitserver, plus cadvisor, blobstore, frontend, codeintel-db, and codeinsights-db. Fix:deepCopythe global and the override too, in all four copies of the helpersourcegraph.redis.confhelper,tests/redisConfigChecksum_test.yaml, and the changelog line are gone, and Git merges that without a conflict. Redis would again restart on every chart version bump whenconfig.enabledis setNOTES.txtreadscadvisor.containerSecurityContext.privileged, which is now an empty override; the container itself still rendersprivileged: truemaininvalues.yaml,README.md, and the syntactic code-intel worker Deployment; thefsGrouplogic from Allow syntactic-code-intel-worker /tmp scratch on a per-pod PVC #987 needs porting to the merged helpersnull.frontend.containerSecurityContext: nullrenderedsecurityContext: nullbefore, and now renders the chart defaults (runAsUser: 100and the rest). Honor an explicit null, or add a breaking-change changelog entryprivate-docker-registryStatefulSet, dind gVisor mode, and executor job podsallowPrivilegeEscalation: falserenders next toprivileged: trueon cadvisor and dind. Kubernetes documents that combination as invalid; not run on a cluster--reuse-values, the stored old defaults act as overrides, and the global is ignored without a messagepgsql-exportergainsallowPrivilegeEscalation: false, so the three database pods restart on upgrade; a newexecutor.enabledvalue in the k8s executor chart gates only the Deployment and ConfigMap; no chart has a changelog entryNOTES.txtNot tested on a cluster: the first three were reproduced with
helm templateand a client-side dry run, and with the conflicts unresolved there is no chart to deploy that matches what would merge.Problem:
containerSecurityContextand / orpodSecurityContext, they generally need to modify the same on all containers or all podsrunAsUser,runAsGroup, andfsGroupon all containers / pods to the same UID / GID assigned to their Kubernetes namespace (OpenShift Project)Solution:
.Values.sourcegraph.containerSecurityContextand.Values.sourcegraph.podSecurityContext, so customers can set the global configs in one place, and if set, override our defaultscontainerSecurityContextandpodSecurityContexttodefaultContainerSecurityContextanddefaultPodSecurityContext, and created emptycontainerSecurityContextandpodSecurityContextkeys, 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
Linked PRs
http-debugport 6060 and theexecutor-<queueName>Service. This PR now deletes them too (4ce480c), so the Service no longer conflicts.executor.Deployment.yamlstill conflicts on one line, next to the removed port: keep this PR'ssourcegraph.containerSecurityContextlineChecklist
Test plan
helm unittestandhelm lintpass, for all 4 chartsTested with helm template commands and compared diffs, using: