PSP are evaluated only when a pod is created directly; when a Deployment or a Daemonset creates a pod, does so using the default serviceaccount of that namespace. Thus, you need to give that SA (or a purposefully create SA) a binding to the appropriate PSP.
Last active
May 1, 2019 11:14
-
-
Save ams0/ee0a6c2c55875d88df037da0212eab59 to your computer and use it in GitHub Desktop.
Create a SA and a binding to the psp:privileged role, then creates a deployment with hostmount
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apiVersion: apps/v1 | |
| kind: Deployment | |
| metadata: | |
| name: nginx-privileged | |
| spec: | |
| selector: | |
| matchLabels: | |
| name: nginx-privileged | |
| template: | |
| metadata: | |
| labels: | |
| name: nginx-privileged | |
| spec: | |
| containers: | |
| - name: nginx-privileged | |
| image: nginx:1.14.2 | |
| securityContext: | |
| privileged: true | |
| volumeMounts: | |
| - name: root-volume | |
| mountPath: /mnt/rootnode | |
| serviceAccountName: default-privileged | |
| volumes: | |
| - hostPath: | |
| path: / | |
| name: root-volume |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apiVersion: v1 | |
| kind: ServiceAccount | |
| metadata: | |
| namespace: default | |
| name: default-privileged | |
| --- | |
| apiVersion: rbac.authorization.k8s.io/v1 | |
| kind: ClusterRoleBinding | |
| metadata: | |
| name: default:privileged | |
| roleRef: | |
| apiGroup: rbac.authorization.k8s.io | |
| kind: ClusterRole | |
| name: psp:privileged | |
| subjects: | |
| - kind: ServiceAccount | |
| namespace: default | |
| name: default-privileged |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment