@@ -681,6 +681,13 @@ func (r *WireguardReconciler) deploymentForWireguard(m *v1alpha1.Wireguard) *app
681681 ls := labelsForWireguard (m .Name )
682682 replicas := int32 (1 )
683683
684+ runAsNonRoot := true
685+ runAsUser := int64 (65534 )
686+ runAsGroup := int64 (65534 )
687+ readOnlyRootFilesystem := true
688+ allowPrivilegeEscalation := false
689+ automountServiceAccountToken := false
690+
684691 dep := & appsv1.Deployment {
685692 ObjectMeta : metav1.ObjectMeta {
686693 Name : m .Name + "-dep" ,
@@ -697,6 +704,12 @@ func (r *WireguardReconciler) deploymentForWireguard(m *v1alpha1.Wireguard) *app
697704 Labels : ls ,
698705 },
699706 Spec : corev1.PodSpec {
707+ SecurityContext : & corev1.PodSecurityContext {
708+ SeccompProfile : & corev1.SeccompProfile {
709+ Type : corev1 .SeccompProfileType ("RuntimeDefault" ),
710+ },
711+ },
712+ AutomountServiceAccountToken : & automountServiceAccountToken ,
700713 Volumes : []corev1.Volume {
701714 {
702715 Name : "socket" ,
@@ -718,7 +731,15 @@ func (r *WireguardReconciler) deploymentForWireguard(m *v1alpha1.Wireguard) *app
718731 Containers : []corev1.Container {
719732 {
720733 SecurityContext : & corev1.SecurityContext {
721- Capabilities : & corev1.Capabilities {Add : []corev1.Capability {"NET_ADMIN" }},
734+ RunAsUser : & runAsUser ,
735+ RunAsGroup : & runAsGroup ,
736+ RunAsNonRoot : & runAsNonRoot ,
737+ ReadOnlyRootFilesystem : & readOnlyRootFilesystem ,
738+ AllowPrivilegeEscalation : & allowPrivilegeEscalation ,
739+ Capabilities : & corev1.Capabilities {
740+ Drop : []corev1.Capability {"ALL" },
741+ Add : []corev1.Capability {"NET_ADMIN" },
742+ },
722743 },
723744 Image : r .AgentImage ,
724745 ImagePullPolicy : r .AgentImagePullPolicy ,
@@ -740,7 +761,9 @@ func (r *WireguardReconciler) deploymentForWireguard(m *v1alpha1.Wireguard) *app
740761 },
741762 {
742763 SecurityContext : & corev1.SecurityContext {
743- Capabilities : & corev1.Capabilities {Add : []corev1.Capability {"NET_ADMIN" }},
764+ ReadOnlyRootFilesystem : & readOnlyRootFilesystem ,
765+ AllowPrivilegeEscalation : & allowPrivilegeEscalation ,
766+ Capabilities : & corev1.Capabilities {Add : []corev1.Capability {"NET_ADMIN" }},
744767 },
745768 Image : r .AgentImage ,
746769 ImagePullPolicy : r .AgentImagePullPolicy ,
0 commit comments