longhorn/examples/rwx/01-security.yaml
Shuo Wu b478c3a1bf example: Fix example rwx
1. Use different names for the 2 roles
(and the related role bindings)
2. Make sure the role binding namespace is the same as the
namespace where nfs provisioner is deployed

Signed-off-by: Shuo Wu <shuo@rancher.com>
2020-07-07 13:09:18 -07:00

86 lines
2.0 KiB
YAML

apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
name: longhorn-nfs-provisioner
spec:
fsGroup:
rule: RunAsAny
allowedCapabilities:
- DAC_READ_SEARCH
- SYS_RESOURCE
runAsUser:
rule: RunAsAny
seLinux:
rule: RunAsAny
supplementalGroups:
rule: RunAsAny
volumes:
- configMap
- downwardAPI
- emptyDir
- persistentVolumeClaim
- secret
- hostPath
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: longhorn-nfs-provisioner
rules:
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["get", "list", "watch", "create", "delete"]
- apiGroups: [""]
resources: ["persistentvolumeclaims"]
verbs: ["get", "list", "watch", "update"]
- apiGroups: ["storage.k8s.io"]
resources: ["storageclasses"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["events"]
verbs: ["create", "update", "patch"]
- apiGroups: [""]
resources: ["services", "endpoints"]
verbs: ["get"]
- apiGroups: ["extensions"]
resources: ["podsecuritypolicies"]
resourceNames: ["nfs-provisioner"]
verbs: ["use"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: longhorn-nfs-provisioner
subjects:
- kind: ServiceAccount
name: longhorn-nfs-provisioner
namespace: longhorn-system
roleRef:
kind: ClusterRole
name: longhorn-nfs-provisioner
apiGroup: rbac.authorization.k8s.io
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: leader-locking-longhorn-nfs-provisioner
namespace: longhorn-system
rules:
- apiGroups: [""]
resources: ["endpoints"]
verbs: ["get", "list", "watch", "create", "update", "patch"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: leader-locking-longhorn-nfs-provisioner
namespace: longhorn-system
subjects:
- kind: ServiceAccount
name: longhorn-nfs-provisioner
namespace: longhorn-system
roleRef:
kind: Role
name: leader-locking-longhorn-nfs-provisioner
apiGroup: rbac.authorization.k8s.io