@@ -273,6 +273,15 @@ func CreateDeployment(name string, namespace string, replicas *int32, owner clie
273273 },
274274 },
275275 Spec : corev1.PodSpec {
276+ SecurityContext : & corev1.PodSecurityContext {
277+ RunAsNonRoot : & []bool {true }[0 ],
278+ RunAsUser : & []int64 {1000 }[0 ],
279+ RunAsGroup : & []int64 {1000 }[0 ],
280+ FSGroup : & []int64 {1000 }[0 ],
281+ SeccompProfile : & corev1.SeccompProfile {
282+ Type : corev1 .SeccompProfileTypeRuntimeDefault ,
283+ },
284+ },
276285 InitContainers : []corev1.Container {
277286 {
278287 Name : "init-assets" ,
@@ -282,6 +291,18 @@ func CreateDeployment(name string, namespace string, replicas *int32, owner clie
282291 "-c" ,
283292 "cp /config/config.yml /www/assets/config.yml && chown -R 1000:1000 /www/assets && chmod -R 755 /www/assets" ,
284293 },
294+ SecurityContext : & corev1.SecurityContext {
295+ AllowPrivilegeEscalation : & []bool {false }[0 ],
296+ RunAsNonRoot : & []bool {true }[0 ],
297+ RunAsUser : & []int64 {1000 }[0 ],
298+ RunAsGroup : & []int64 {1000 }[0 ],
299+ Capabilities : & corev1.Capabilities {
300+ Drop : []corev1.Capability {"ALL" },
301+ },
302+ SeccompProfile : & corev1.SeccompProfile {
303+ Type : corev1 .SeccompProfileTypeRuntimeDefault ,
304+ },
305+ },
285306 VolumeMounts : []corev1.VolumeMount {
286307 {
287308 Name : "config-volume" ,
@@ -298,6 +319,18 @@ func CreateDeployment(name string, namespace string, replicas *int32, owner clie
298319 {
299320 Name : name ,
300321 Image : image ,
322+ SecurityContext : & corev1.SecurityContext {
323+ AllowPrivilegeEscalation : & []bool {false }[0 ],
324+ RunAsNonRoot : & []bool {true }[0 ],
325+ RunAsUser : & []int64 {1000 }[0 ],
326+ RunAsGroup : & []int64 {1000 }[0 ],
327+ Capabilities : & corev1.Capabilities {
328+ Drop : []corev1.Capability {"ALL" },
329+ },
330+ SeccompProfile : & corev1.SeccompProfile {
331+ Type : corev1 .SeccompProfileTypeRuntimeDefault ,
332+ },
333+ },
301334 VolumeMounts : []corev1.VolumeMount {
302335 {
303336 Name : "assets-volume" ,
@@ -585,6 +618,15 @@ func CreateDeploymentWithAssets(name string, namespace string, replicas *int32,
585618 },
586619 },
587620 Spec : corev1.PodSpec {
621+ SecurityContext : & corev1.PodSecurityContext {
622+ RunAsNonRoot : & []bool {true }[0 ],
623+ RunAsUser : & []int64 {1000 }[0 ],
624+ RunAsGroup : & []int64 {1000 }[0 ],
625+ FSGroup : & []int64 {1000 }[0 ],
626+ SeccompProfile : & corev1.SeccompProfile {
627+ Type : corev1 .SeccompProfileTypeRuntimeDefault ,
628+ },
629+ },
588630 InitContainers : []corev1.Container {
589631 {
590632 Name : "init-assets" ,
@@ -594,13 +636,37 @@ func CreateDeploymentWithAssets(name string, namespace string, replicas *int32,
594636 "-c" ,
595637 initCommand ,
596638 },
639+ SecurityContext : & corev1.SecurityContext {
640+ AllowPrivilegeEscalation : & []bool {false }[0 ],
641+ RunAsNonRoot : & []bool {true }[0 ],
642+ RunAsUser : & []int64 {1000 }[0 ],
643+ RunAsGroup : & []int64 {1000 }[0 ],
644+ Capabilities : & corev1.Capabilities {
645+ Drop : []corev1.Capability {"ALL" },
646+ },
647+ SeccompProfile : & corev1.SeccompProfile {
648+ Type : corev1 .SeccompProfileTypeRuntimeDefault ,
649+ },
650+ },
597651 VolumeMounts : initVolumeMounts ,
598652 },
599653 },
600654 Containers : []corev1.Container {
601655 {
602656 Name : name ,
603657 Image : image ,
658+ SecurityContext : & corev1.SecurityContext {
659+ AllowPrivilegeEscalation : & []bool {false }[0 ],
660+ RunAsNonRoot : & []bool {true }[0 ],
661+ RunAsUser : & []int64 {1000 }[0 ],
662+ RunAsGroup : & []int64 {1000 }[0 ],
663+ Capabilities : & corev1.Capabilities {
664+ Drop : []corev1.Capability {"ALL" },
665+ },
666+ SeccompProfile : & corev1.SeccompProfile {
667+ Type : corev1 .SeccompProfileTypeRuntimeDefault ,
668+ },
669+ },
604670 VolumeMounts : []corev1.VolumeMount {
605671 {
606672 Name : "assets-volume" ,
0 commit comments