@@ -57,10 +57,10 @@ const (
5757
5858 EnvGoFunctionConfigs = "GO_FUNCTION_CONF"
5959
60- DefaultRunnerUserID = "10001"
61- DefaultRunnerUser = "pulsar"
62- DefaultRunnerGroupID = "10000"
63- DefaultRunnerGroup = "pulsar"
60+ DefaultRunnerUserID int64 = 10000
61+ DefaultRunnerUser = "pulsar"
62+ DefaultRunnerGroupID int64 = 10001
63+ DefaultRunnerGroup = "pulsar"
6464)
6565
6666var GRPCPort = corev1.ContainerPort {
@@ -136,6 +136,10 @@ func MakeStatefulSetSpec(replicas *int32, container *corev1.Container,
136136
137137func MakePodTemplate (container * corev1.Container , volumes []corev1.Volume ,
138138 labels map [string ]string , policy v1alpha1.PodPolicy ) * corev1.PodTemplateSpec {
139+ podSecurityContext := getDefaultRunnerPodSecurityContext (DefaultRunnerUserID , DefaultRunnerGroupID , false )
140+ if policy .SecurityContext != nil {
141+ podSecurityContext = policy .SecurityContext
142+ }
139143 return & corev1.PodTemplateSpec {
140144 ObjectMeta : metav1.ObjectMeta {
141145 Labels : mergeLabels (labels , policy .Labels ),
@@ -149,7 +153,7 @@ func MakePodTemplate(container *corev1.Container, volumes []corev1.Volume,
149153 NodeSelector : policy .NodeSelector ,
150154 Affinity : policy .Affinity ,
151155 Tolerations : policy .Tolerations ,
152- SecurityContext : policy . SecurityContext ,
156+ SecurityContext : podSecurityContext ,
153157 ImagePullSecrets : policy .ImagePullSecrets ,
154158 ServiceAccountName : policy .ServiceAccountName ,
155159 },
@@ -382,6 +386,9 @@ func getProcessGoRuntimeArgs(goExecFilePath string, function *v1alpha1.Function)
382386 "&&" ,
383387 "echo goFunctionConfigs=\" '${goFunctionConfigs}'\" " ,
384388 "&&" ,
389+ "ls -l" ,
390+ goExecFilePath ,
391+ "&&" ,
385392 "chmod +x" ,
386393 goExecFilePath ,
387394 "&&" ,
@@ -655,6 +662,16 @@ func getSourceRunnerImage(spec *v1alpha1.SourceSpec) string {
655662 return DefaultRunnerImage
656663}
657664
665+ // getDefaultRunnerPodSecurityContext returns a default PodSecurityContext that runs as non-root
666+ func getDefaultRunnerPodSecurityContext (uid , gid int64 , nonRoot bool ) * corev1.PodSecurityContext {
667+ return & corev1.PodSecurityContext {
668+ RunAsUser : & uid ,
669+ RunAsGroup : & gid ,
670+ RunAsNonRoot : & nonRoot ,
671+ FSGroup : & gid ,
672+ }
673+ }
674+
658675func getJavaSecretProviderArgs (secretMaps map [string ]v1alpha1.SecretRef ) []string {
659676 var ret []string
660677 if len (secretMaps ) > 0 {
0 commit comments