Skip to content

Commit b7a5b0f

Browse files
author
OpenShift Bot
authored
Merge pull request #12733 from mfojtik/lifecycle_security
Merged by openshift-bot
2 parents ed285a1 + d026451 commit b7a5b0f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pkg/deploy/strategy/support/lifecycle.go

+16
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,20 @@ func makeHookPod(hook *deployapi.LifecycleHook, rc *kapi.ReplicationController,
375375

376376
gracePeriod := int64(10)
377377

378+
var podSecurityContextCopy *kapi.PodSecurityContext
379+
if ctx, err := kapi.Scheme.DeepCopy(rc.Spec.Template.Spec.SecurityContext); err != nil {
380+
return nil, fmt.Errorf("unable to copy pod securityContext: %v", err)
381+
} else {
382+
podSecurityContextCopy = ctx.(*kapi.PodSecurityContext)
383+
}
384+
385+
var securityContextCopy *kapi.SecurityContext
386+
if ctx, err := kapi.Scheme.DeepCopy(baseContainer.SecurityContext); err != nil {
387+
return nil, fmt.Errorf("unable to copy securityContext: %v", err)
388+
} else {
389+
securityContextCopy = ctx.(*kapi.SecurityContext)
390+
}
391+
378392
pod := &kapi.Pod{
379393
ObjectMeta: kapi.ObjectMeta{
380394
Name: namer.GetPodName(rc.Name, suffix),
@@ -397,8 +411,10 @@ func makeHookPod(hook *deployapi.LifecycleHook, rc *kapi.ReplicationController,
397411
Env: mergedEnv,
398412
Resources: resources,
399413
VolumeMounts: volumeMounts,
414+
SecurityContext: securityContextCopy,
400415
},
401416
},
417+
SecurityContext: podSecurityContextCopy,
402418
Volumes: volumes,
403419
ActiveDeadlineSeconds: &maxDeploymentDurationSeconds,
404420
// Setting the node selector on the hook pod so that it is created

0 commit comments

Comments
 (0)