@@ -25,6 +25,7 @@ import (
2525
2626 authorizationv1 "k8s.io/api/authorization/v1"
2727 corev1 "k8s.io/api/core/v1"
28+ v1 "k8s.io/api/core/v1"
2829 "k8s.io/apimachinery/pkg/api/errors"
2930 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3031 "k8s.io/apimachinery/pkg/util/intstr"
@@ -34,6 +35,7 @@ import (
3435 "k8s.io/client-go/rest"
3536 "k8s.io/client-go/tools/clientcmd"
3637 cmdapi "k8s.io/client-go/tools/clientcmd/api"
38+ "k8s.io/utils/pointer"
3739
3840 configv1 "github.com/openshift/api/config/v1"
3941 routev1 "github.com/openshift/api/route/v1"
@@ -667,6 +669,7 @@ func newOAuthProxyPod(proxyImage, backendImage string, extraProxyArgs []string,
667669 "--cookie-secret=SECRET" ,
668670 "--skip-provider-button" ,
669671 }, extraProxyArgs ... )
672+
670673 return & corev1.Pod {
671674 ObjectMeta : metav1.ObjectMeta {
672675 Name : "proxy" ,
@@ -675,6 +678,11 @@ func newOAuthProxyPod(proxyImage, backendImage string, extraProxyArgs []string,
675678 },
676679 },
677680 Spec : corev1.PodSpec {
681+ SecurityContext : & v1.PodSecurityContext {
682+ RunAsNonRoot : pointer .Bool (true ),
683+ RunAsUser : pointer .Int64 (1000 ),
684+ SeccompProfile : & v1.SeccompProfile {Type : v1 .SeccompProfileTypeRuntimeDefault },
685+ },
678686 Volumes : []corev1.Volume {
679687 {
680688 Name : "proxy-cert-volume" ,
@@ -692,6 +700,10 @@ func newOAuthProxyPod(proxyImage, backendImage string, extraProxyArgs []string,
692700 ImagePullPolicy : corev1 .PullIfNotPresent ,
693701 Name : "oauth-proxy" ,
694702 Args : proxyArgs ,
703+ SecurityContext : & v1.SecurityContext {
704+ AllowPrivilegeEscalation : pointer .Bool (false ),
705+ Capabilities : & v1.Capabilities {Drop : []v1.Capability {"ALL" }},
706+ },
695707 Ports : []corev1.ContainerPort {
696708 {
697709 ContainerPort : 8443 ,
@@ -707,6 +719,10 @@ func newOAuthProxyPod(proxyImage, backendImage string, extraProxyArgs []string,
707719 {
708720 Image : backendImage ,
709721 Name : "hello-openshift" ,
722+ SecurityContext : & v1.SecurityContext {
723+ AllowPrivilegeEscalation : pointer .Bool (false ),
724+ Capabilities : & v1.Capabilities {Drop : []v1.Capability {"ALL" }},
725+ },
710726 Ports : []corev1.ContainerPort {
711727 {
712728 ContainerPort : 8080 ,
0 commit comments