-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpodsecuritypolicies.yaml
executable file
·237 lines (202 loc) · 4.77 KB
/
podsecuritypolicies.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
creationTimestamp: null
name: pod-security-policy-default
spec:
fsGroup:
rule: RunAsAny
runAsUser:
rule: RunAsAny
seLinux:
rule: RunAsAny
supplementalGroups:
rule: RunAsAny
volumes:
- emptyDir
- secret
- configMap
- persistentVolumeClaim
---
# Cluster role which grants access to the default pod security policy
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: default-psp
rules:
- apiGroups:
- policy
resourceNames:
- pod-security-policy-default
resources:
- podsecuritypolicies
verbs:
- use
---
# Cluster role binding for default pod security policy granting all authenticated users access
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: default-psp
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: default-psp
subjects:
- apiGroup: rbac.authorization.k8s.io
kind: Group
name: system:authenticated
- kind: ServiceAccount
name: replicaset-controller
namespace: kube-system
---
# Should grant access to very few pods, i.e. kube-system system pods and possibly CNI pods
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
annotations:
# See https://kubernetes.io/docs/concepts/policy/pod-security-policy/#seccomp
seccomp.security.alpha.kubernetes.io/allowedProfileNames: '*'
name: privilegedx
spec:
allowedCapabilities:
- '*'
allowPrivilegeEscalation: true
fsGroup:
rule: 'RunAsAny'
hostIPC: true
hostNetwork: true
hostPID: true
hostPorts:
- min: 0
max: 65535
privileged: true
readOnlyRootFilesystem: false
runAsUser:
rule: 'RunAsAny'
seLinux:
rule: 'RunAsAny'
supplementalGroups:
rule: 'RunAsAny'
volumes:
- '*'
---
# Cluster role which grants access to the privileged pod security policy
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: privileged-psp
namespace: kube-system
rules:
- apiGroups:
- policy
resourceNames:
- privilegedx
resources:
- podsecuritypolicies
verbs:
- use
---
# Role binding for kube-system - allow nodes and kube-system service accounts - should take care of CNI i.e. flannel running in the kube-system namespace
# Assumes access to the kube-system is restricted
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: kube-system-psp
namespace: kube-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: privileged-psp
subjects:
# For the kubeadm kube-system nodes
- apiGroup: rbac.authorization.k8s.io
kind: Group
name: system:nodes
- kind: ServiceAccount
namespace: kube-system
name: attachdetach-controller
- kind: ServiceAccount
namespace: kube-system
name: pvc-protection-controller
- kind: ServiceAccount
namespace: kube-system
name: pv-protection-controller
- kind: ServiceAccount
namespace: kube-system
name: pod-garbage-collector
- kind: ServiceAccount
namespace: kube-system
name: persistent-volume-binder
- kind: ServiceAccount
namespace: kube-system
name: node-controller
- kind: ServiceAccount
namespace: kube-system
name: namespace-controller
- kind: ServiceAccount
namespace: kube-system
name: kube-proxy
- kind: ServiceAccount
namespace: kube-system
name: job-controller
- kind: ServiceAccount
namespace: kube-system
name: horizontal-pod-autoscaler
- kind: ServiceAccount
namespace: kube-system
name: generic-garbage-collector
- kind: ServiceAccount
namespace: kube-system
name: expand-controller
- kind: ServiceAccount
namespace: kube-system
name: endpoint-controller
- kind: ServiceAccount
namespace: kube-system
name: disruption-controller
- kind: ServiceAccount
namespace: kube-system
name: default
- kind: ServiceAccount
namespace: kube-system
name: daemon-set-controller
- kind: ServiceAccount
namespace: kube-system
name: cronjob-controller
- kind: ServiceAccount
namespace: kube-system
name: coredns
- kind: ServiceAccount
namespace: kube-system
name: clusterrole-aggregation-controller
- kind: ServiceAccount
namespace: kube-system
name: certificate-controller
- kind: ServiceAccount
namespace: kube-system
name: canal
- kind: ServiceAccount
namespace: kube-system
name: bootstrap-signer
- kind: ServiceAccount
namespace: kube-system
name: replication-controller
- kind: ServiceAccount
namespace: kube-system
name: resourcequota-controller
- kind: ServiceAccount
namespace: kube-system
name: service-account-controller
- kind: ServiceAccount
namespace: kube-system
name: service-controller
- kind: ServiceAccount
namespace: kube-system
name: statefulset-controller
- kind: ServiceAccount
namespace: kube-system
name: token-cleaner
- kind: ServiceAccount
namespace: kube-system
name: ttl-controller