File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import (
1919 clientset "k8s.io/client-go/kubernetes"
2020 e2ekubectl "k8s.io/kubernetes/test/e2e/framework/kubectl"
2121 e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
22+ "k8s.io/utils/ptr"
2223
2324 mnpapi "github.com/k8snetworkplumbingwg/multi-networkpolicy/pkg/apis/k8s.cni.cncf.io/v1beta1"
2425 nadapi "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1"
@@ -166,8 +167,19 @@ func generatePodSpec(config podConfiguration) *v1.Pod {
166167 podSpec .Spec .NodeSelector = config .nodeSelector
167168 podSpec .Labels = config .labels
168169 if config .isPrivileged {
169- privileged := true
170- podSpec .Spec .Containers [0 ].SecurityContext .Privileged = & privileged
170+ podSpec .Spec .Containers [0 ].SecurityContext .Privileged = ptr .To (true )
171+ } else {
172+ for _ , container := range podSpec .Spec .Containers {
173+ if container .SecurityContext .Capabilities == nil {
174+ container .SecurityContext .Capabilities = & v1.Capabilities {}
175+ }
176+ container .SecurityContext .Capabilities .Drop = []v1.Capability {"ALL" }
177+ container .SecurityContext .Privileged = ptr .To (false )
178+ container .SecurityContext .RunAsNonRoot = ptr .To (true )
179+ container .SecurityContext .RunAsUser = ptr .To (int64 (1000 ))
180+ container .SecurityContext .AllowPrivilegeEscalation = ptr .To (false )
181+ container .SecurityContext .SeccompProfile = & v1.SeccompProfile {Type : v1 .SeccompProfileTypeRuntimeDefault }
182+ }
171183 }
172184 return podSpec
173185}
You can’t perform that action at this time.
0 commit comments