@@ -11,7 +11,8 @@ weight: 30
11
11
12
12
{{< feature-state for_k8s_version="v1.21" state="deprecated" >}}
13
13
14
- PodSecurityPolicy is deprecated as of Kubernetes v1.21, and will be removed in v1.25.
14
+ PodSecurityPolicy is deprecated as of Kubernetes v1.21, and will be removed in v1.25. For more information on the deprecation,
15
+ see [ PodSecurityPolicy Deprecation: Past, Present, and Future] ( /blog/2021/04/06/podsecuritypolicy-deprecation-past-present-and-future/ ) .
15
16
16
17
Pod Security Policies enable fine-grained authorization of pod creation and
17
18
updates.
@@ -110,6 +111,10 @@ roleRef:
110
111
name: <role name>
111
112
apiGroup: rbac.authorization.k8s.io
112
113
subjects:
114
+ # Authorize all service accounts in a namespace (recommended):
115
+ - kind: Group
116
+ apiGroup: rbac.authorization.k8s.io
117
+ name: system:serviceaccounts:<authorized namespace>
113
118
# Authorize specific service accounts:
114
119
- kind: ServiceAccount
115
120
name: <authorized service account name>
@@ -139,6 +144,39 @@ Examples](/docs/reference/access-authn-authz/rbac#role-binding-examples).
139
144
For a complete example of authorizing a PodSecurityPolicy, see
140
145
[below](#example).
141
146
147
+ # ## Best Practices
148
+
149
+ PodSecurityPolicy is being replaced by a new, simplified PodSecurity admission controller. The
150
+ following recommended best-practices will make the migration to the new PodSecurity admission
151
+ controller much simpler. For more details on this change, see
152
+ [PodSecurityPolicy Deprecation : Past, Present, and Future](/blog/2021/04/06/podsecuritypolicy-deprecation-past-present-and-future/).
153
+
154
+ 1. Limit your PodSecurityPolicies to the policies defined by the [Pod Security Standards](/docs/concepts/security/pod-security-standards) :
155
+ - [Privileged](https://raw.githubusercontent.com/kubernetes/website/master/content/en/examples/policy/privileged-psp.yaml)
156
+ - [Baseline](https://raw.githubusercontent.com/kubernetes/website/master/content/en/examples/policy/baseline-psp.yaml)
157
+ - [Restricted](https://raw.githubusercontent.com/kubernetes/website/master/content/en/examples/policy/restricted-psp.yaml)
158
+
159
+ 2. Only bind PSPs to namespaces, by using the `system:serviceaccounts:<namespace>` group (where
160
+ `<namespace>` is the target namespace). For example :
161
+
162
+ ` ` ` yaml
163
+ apiVersion: rbac.authorization.k8s.io/v1
164
+ # This cluster role binding allows all pods in the "development" namespace to use the baseline PSP.
165
+ kind: ClusterRoleBinding
166
+ metadata:
167
+ name: psp-baseline-namespaces
168
+ roleRef:
169
+ kind: ClusterRole
170
+ name: psp-baseline
171
+ apiGroup: rbac.authorization.k8s.io
172
+ subjects:
173
+ - kind: Group
174
+ name: system:serviceaccounts:development
175
+ apiGroup: rbac.authorization.k8s.io
176
+ - kind: Group
177
+ name: system:serviceaccounts:canary
178
+ apiGroup: rbac.authorization.k8s.io
179
+ ` ` `
142
180
143
181
# ## Troubleshooting
144
182
0 commit comments