Skip to content

Commit

Permalink
feat: support container security context
Browse files Browse the repository at this point in the history
  • Loading branch information
yetone committed Dec 6, 2022
1 parent ae4fb4e commit 547319a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions controllers/bentodeployment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1614,6 +1614,22 @@ func (r *BentoDeploymentReconciler) generatePodTemplateSpec(ctx context.Context,
},
}

if resourceAnnotations["yatai.ai/enable-container-privileged"] == consts.KubeLabelTrue {
if container.SecurityContext == nil {
container.SecurityContext = &corev1.SecurityContext{}
}
container.SecurityContext.Privileged = &[]bool{true}[0]
}

if resourceAnnotations["yatai.ai/enable-container-ptrace"] == consts.KubeLabelTrue {
if container.SecurityContext == nil {
container.SecurityContext = &corev1.SecurityContext{}
}
container.SecurityContext.Capabilities = &corev1.Capabilities{
Add: []corev1.Capability{"SYS_PTRACE"},
}
}

containers = append(containers, container)

metricsPort := containerPort + 1
Expand Down

0 comments on commit 547319a

Please sign in to comment.