Skip to content

Commit 8d9383e

Browse files
committed
deployment: carry over the securityContext from the deployment config to lifecycle hook
1 parent badb6ac commit 8d9383e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/deploy/strategy/support/lifecycle.go

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

376376
gracePeriod := int64(10)
377377

378+
podSecurityContext, err := kapi.Scheme.DeepCopy(rc.Spec.Template.Spec.SecurityContext)
379+
if err != nil {
380+
return nil, fmt.Errorf("unable to copy pod securityContext: %v", err)
381+
}
382+
378383
pod := &kapi.Pod{
379384
ObjectMeta: kapi.ObjectMeta{
380385
Name: namer.GetPodName(rc.Name, suffix),
@@ -397,8 +402,10 @@ func makeHookPod(hook *deployapi.LifecycleHook, rc *kapi.ReplicationController,
397402
Env: mergedEnv,
398403
Resources: resources,
399404
VolumeMounts: volumeMounts,
405+
SecurityContext: baseContainer.SecurityContext,
400406
},
401407
},
408+
SecurityContext: podSecurityContext,
402409
Volumes: volumes,
403410
ActiveDeadlineSeconds: &maxDeploymentDurationSeconds,
404411
// Setting the node selector on the hook pod so that it is created

0 commit comments

Comments
 (0)