Skip to content

Commit

Permalink
Remove explicit securityContext and add granular securitycontextconst…
Browse files Browse the repository at this point in the history
…raints use permissions in machine-api-controllers clusterRole

Without the runlabel openshift#496, we’ll run as a high user by default, no need to say run me as non root. Otherwise when removing the runlevel completely for the openshift-machine-api namespace openshift/cluster-autoscaler-operator#133 the kube controller manager complains with 'Error creating: pods "machine-api-operator-75c887884f-" is forbidden: unable to validate against any security context constraint: [spec.containers[0].securityContext.securityContext.runAsUser: Invalid value: 65534: must be in the ranges: [1000340000, 1000349999] spec.containers[1].securityContext.securityContext.runAsUser: Invalid value: 65534: must be in the ranges: [1000340000, 1000349999]]' https://storage.googleapis.com/origin-ci-test/pr-logs/pull/openshift_cluster-autoscaler-operator/133/pull-ci-openshift-cluster-autoscaler-operator-master-e2e-aws/496/artifacts/e2e-aws/pods/openshift-kube-controller-manager_kube-controller-manager-ip-10-0-133-251.us-east-2.compute.internal_kube-controller-manager.log"
  • Loading branch information
enxebre authored and openshift-cherrypick-robot committed Jul 7, 2020
1 parent 409274d commit bf148ba
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
10 changes: 10 additions & 0 deletions install/0000_30_machine-api-operator_09_rbac.yaml
Expand Up @@ -151,6 +151,16 @@ rules:
- list
- watch

# the baremetal pod deployment uses hostNetwork, hostPort, and privileged
- apiGroups:
- security.openshift.io
resources:
- securitycontextconstraints
verbs:
- use
resourceNames:
- privileged

---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
Expand Down
3 changes: 0 additions & 3 deletions install/0000_30_machine-api-operator_11_deployment.yaml
Expand Up @@ -68,9 +68,6 @@ spec:
nodeSelector:
node-role.kubernetes.io/master: ""
restartPolicy: Always
securityContext:
runAsNonRoot: true
runAsUser: 65534
tolerations:
- key: "node-role.kubernetes.io/master"
operator: "Exists"
Expand Down
10 changes: 3 additions & 7 deletions pkg/operator/sync.go
Expand Up @@ -188,13 +188,9 @@ func newPodTemplateSpec(config *OperatorConfig, features map[string]bool) *corev
},
},
Spec: corev1.PodSpec{
Containers: containers,
PriorityClassName: "system-node-critical",
NodeSelector: map[string]string{"node-role.kubernetes.io/master": ""},
SecurityContext: &corev1.PodSecurityContext{
RunAsNonRoot: pointer.BoolPtr(true),
RunAsUser: pointer.Int64Ptr(65534),
},
Containers: containers,
PriorityClassName: "system-node-critical",
NodeSelector: map[string]string{"node-role.kubernetes.io/master": ""},
ServiceAccountName: "machine-api-controllers",
Tolerations: tolerations,
},
Expand Down

0 comments on commit bf148ba

Please sign in to comment.