Skip to content

Commit

Permalink
Unset Worker SecurityContexts when pachd.securityContext.enabled=false (
Browse files Browse the repository at this point in the history
#7218) (#7223)

Exposing pachd env-var ENABLE_WORKER_SECURITY_CONTEXTS that is set to false when helm's pachd.securityContext.enabled=false
  • Loading branch information
acohen4 committed Jan 5, 2022
1 parent 4b702d8 commit e5a13d9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions etc/helm/pachyderm/templates/pachd/deployment.yaml
Expand Up @@ -160,6 +160,8 @@ spec:
- name: NO_PROXY
value: {{.Values.global.noProxy}}
{{ end }}
- name: ENABLE_WORKER_SECURITY_CONTEXTS
value: {{ .Values.pachd.securityContext.enabled | quote }}
envFrom:
- secretRef:
name: pachyderm-storage-secret
Expand Down
3 changes: 2 additions & 1 deletion src/internal/serviceenv/config.go
Expand Up @@ -93,7 +93,8 @@ type PachdSpecificConfiguration struct {
WorkerUsesRoot bool `env:"WORKER_USES_ROOT,default=false"`
RequireCriticalServersOnly bool `env:"REQUIRE_CRITICAL_SERVERS_ONLY,default=false"`
// TODO: Merge this with the worker specific pod name (PPS_POD_NAME) into a global configuration pod name.
PachdPodName string `env:"PACHD_POD_NAME,required"`
PachdPodName string `env:"PACHD_POD_NAME,required"`
EnableWorkerSecurityContexts bool `env:"ENABLE_WORKER_SECURITY_CONTEXTS,default=true"`
}

// StorageConfiguration contains the storage configuration.
Expand Down
5 changes: 4 additions & 1 deletion src/server/pps/server/worker_rc.go
Expand Up @@ -300,7 +300,10 @@ func (a *apiServer) workerPodSpec(options *workerOptions, pipelineInfo *pps.Pipe
}
var userSecurityCtx *v1.SecurityContext
userStr := pipelineInfo.Details.Transform.User
if a.workerUsesRoot {

if !a.env.Config().EnableWorkerSecurityContexts {
pachSecurityCtx = nil
} else if a.workerUsesRoot {
pachSecurityCtx = &v1.SecurityContext{RunAsUser: int64Ptr(0)}
userSecurityCtx = &v1.SecurityContext{RunAsUser: int64Ptr(0)}
} else if userStr != "" {
Expand Down

0 comments on commit e5a13d9

Please sign in to comment.