-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathclusterrole_restricted.yaml
57 lines (57 loc) · 1.22 KB
/
clusterrole_restricted.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Create the 'secure' namespace representing a single tenant instance
apiVersion: v1
kind: Namespace
metadata:
name: secure
---
# Create a PSP that has some restrictions, but is missing others
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
name: restricted
spec:
privileged: false
seLinux:
rule: RunAsAny
supplementalGroups:
rule: RunAsAny
runAsUser:
# Require the container to run without root privileges.
rule: 'MustRunAsNonRoot'
fsGroup:
rule: RunAsAny
volumes:
- '*'
---
# Make the PSP available within the cluster
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: restricted-clusterrole
rules:
- apiGroups:
- policy
resources:
- podsecuritypolicies
resourceNames:
- restricted
verbs:
- use
---
# Bind the PSP (ClusterRole) to all service accounts within the "secure"
# namespace
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: restricted-crb
namespace: secure
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: restricted-clusterrole
subjects:
# Example: All service accounts in my-namespace
- apiGroup: rbac.authorization.k8s.io
kind: Group
name: system:serviceaccounts
#namespace: secure