@@ -344,6 +344,14 @@ async def ensure_image_pre_puller_daemonset(self) -> None:
344344 init_containers : list [k8s_client .V1Container ] = []
345345 all_images = {config .image for lang in RUNTIME_REGISTRY .values () for config in lang .values ()}
346346
347+ psa_security_context = k8s_client .V1SecurityContext (
348+ allow_privilege_escalation = False ,
349+ capabilities = k8s_client .V1Capabilities (drop = ["ALL" ]),
350+ run_as_non_root = True ,
351+ run_as_user = 65534 ,
352+ seccomp_profile = k8s_client .V1SeccompProfile (type = "RuntimeDefault" ),
353+ )
354+
347355 for i , image_ref in enumerate (sorted (all_images )):
348356 sanitized_image_ref = image_ref .split ("/" )[- 1 ].replace (":" , "-" ).replace ("." , "-" ).replace ("_" , "-" )
349357 self .logger .info (f"DAEMONSET: before: { image_ref } -> { sanitized_image_ref } " )
@@ -352,6 +360,7 @@ async def ensure_image_pre_puller_daemonset(self) -> None:
352360 image = image_ref ,
353361 command = ["/bin/sh" , "-c" , f'echo "Image { image_ref } pulled."' ],
354362 image_pull_policy = "Always" ,
363+ security_context = psa_security_context ,
355364 ))
356365
357366 daemonset = k8s_client .V1DaemonSet (
@@ -366,8 +375,14 @@ async def ensure_image_pre_puller_daemonset(self) -> None:
366375 init_containers = init_containers ,
367376 containers = [k8s_client .V1Container (
368377 name = "pause" , image = "registry.k8s.io/pause:3.9" ,
378+ security_context = psa_security_context ,
369379 )],
370380 tolerations = [k8s_client .V1Toleration (operator = "Exists" )],
381+ security_context = k8s_client .V1PodSecurityContext (
382+ run_as_non_root = True ,
383+ run_as_user = 65534 ,
384+ seccomp_profile = k8s_client .V1SeccompProfile (type = "RuntimeDefault" ),
385+ ),
371386 ),
372387 ),
373388 update_strategy = k8s_client .V1DaemonSetUpdateStrategy (type = "RollingUpdate" ),
0 commit comments