Skip to content

Commit

Permalink
deployment: carry over the securityContext from the deployment config…
Browse files Browse the repository at this point in the history
… to lifecycle hook
  • Loading branch information
mfojtik committed Apr 5, 2017
1 parent f0670df commit d026451
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/deploy/strategy/support/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,20 @@ func makeHookPod(hook *deployapi.LifecycleHook, rc *kapi.ReplicationController,

gracePeriod := int64(10)

var podSecurityContextCopy *kapi.PodSecurityContext
if ctx, err := kapi.Scheme.DeepCopy(rc.Spec.Template.Spec.SecurityContext); err != nil {
return nil, fmt.Errorf("unable to copy pod securityContext: %v", err)
} else {
podSecurityContextCopy = ctx.(*kapi.PodSecurityContext)
}

var securityContextCopy *kapi.SecurityContext
if ctx, err := kapi.Scheme.DeepCopy(baseContainer.SecurityContext); err != nil {
return nil, fmt.Errorf("unable to copy securityContext: %v", err)
} else {
securityContextCopy = ctx.(*kapi.SecurityContext)
}

pod := &kapi.Pod{
ObjectMeta: kapi.ObjectMeta{
Name: namer.GetPodName(rc.Name, suffix),
Expand All @@ -397,8 +411,10 @@ func makeHookPod(hook *deployapi.LifecycleHook, rc *kapi.ReplicationController,
Env: mergedEnv,
Resources: resources,
VolumeMounts: volumeMounts,
SecurityContext: securityContextCopy,
},
},
SecurityContext: podSecurityContextCopy,
Volumes: volumes,
ActiveDeadlineSeconds: &maxDeploymentDurationSeconds,
// Setting the node selector on the hook pod so that it is created
Expand Down

0 comments on commit d026451

Please sign in to comment.