Skip to content

Commit

Permalink
Merge pull request #51 from awels/remove_run_as_non_root
Browse files Browse the repository at this point in the history
Run as user 1000, no need to be root.
  • Loading branch information
awels committed Feb 14, 2020
2 parents 6175e42 + f0e68a9 commit fc3a44f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions deploy/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ spec:
labels:
name: hostpath-provisioner-operator
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
serviceAccountName: hostpath-provisioner-operator
containers:
- name: hostpath-provisioner-operator
Expand Down
2 changes: 2 additions & 0 deletions tools/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func WithOperatorLabels(labels map[string]string) map[string]string {
//CreateOperatorDeploymentSpec creates deployment
func CreateOperatorDeploymentSpec(name, namespace, matchKey, matchValue, serviceAccount string, numReplicas int32) *appsv1.DeploymentSpec {
matchMap := map[string]string{matchKey: matchValue}
user := int64(1000)
spec := &appsv1.DeploymentSpec{
Replicas: &numReplicas,
Selector: &metav1.LabelSelector{
Expand All @@ -58,6 +59,7 @@ func CreateOperatorDeploymentSpec(name, namespace, matchKey, matchValue, service
Spec: corev1.PodSpec{
SecurityContext: &corev1.PodSecurityContext{
RunAsNonRoot: &[]bool{true}[0],
RunAsUser: &user,
},
},
},
Expand Down

0 comments on commit fc3a44f

Please sign in to comment.