@@ -224,13 +224,29 @@ func (r PodTestRunner) RunTest(ctx context.Context, test v1alpha3.TestConfigurat
224
224
// Create a Pod to run the test
225
225
podDef := getPodDefinition (r .configMapName , test , r )
226
226
if podSec {
227
- secCtx := v1.PodSecurityContext {}
228
- secCtx .RunAsNonRoot = & podSec
229
- secCtx .SeccompProfile = & v1.SeccompProfile {
227
+ // creating a pod security context to support running in default namespace
228
+ podSecCtx := v1.PodSecurityContext {}
229
+ podSecCtx .RunAsNonRoot = & podSec
230
+ podSecCtx .RunAsUser = & []int64 {1000 }[0 ]
231
+ podSecCtx .RunAsGroup = & []int64 {1000 }[0 ]
232
+ podSecCtx .SeccompProfile = & v1.SeccompProfile {
230
233
Type : v1 .SeccompProfileTypeRuntimeDefault ,
231
234
}
232
235
233
- podDef .Spec .SecurityContext = & secCtx
236
+ // creating a security context to be used by all containers in the pod
237
+ secCtx := v1.SecurityContext {}
238
+ secCtx .RunAsNonRoot = & podSec
239
+ secCtx .AllowPrivilegeEscalation = & []bool {false }[0 ]
240
+ secCtx .Capabilities = & v1.Capabilities {
241
+ Drop : []v1.Capability {
242
+ "ALL" ,
243
+ },
244
+ }
245
+
246
+ podDef .Spec .SecurityContext = & podSecCtx
247
+
248
+ podDef .Spec .Containers [0 ].SecurityContext = & secCtx
249
+ podDef .Spec .InitContainers [0 ].SecurityContext = & secCtx
234
250
}
235
251
236
252
if test .Storage .Spec .MountPath .Path != "" {
0 commit comments