Skip to content

Commit 4600715

Browse files
committed
Document PSP best practices for PodSecurity transition
1 parent 6cc9bf8 commit 4600715

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

content/en/docs/concepts/policy/pod-security-policy.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ weight: 30
1111

1212
{{< feature-state for_k8s_version="v1.21" state="deprecated" >}}
1313

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/).
1516

1617
Pod Security Policies enable fine-grained authorization of pod creation and
1718
updates.
@@ -110,6 +111,10 @@ roleRef:
110111
name: <role name>
111112
apiGroup: rbac.authorization.k8s.io
112113
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>
113118
# Authorize specific service accounts:
114119
- kind: ServiceAccount
115120
name: <authorized service account name>
@@ -139,6 +144,39 @@ Examples](/docs/reference/access-authn-authz/rbac#role-binding-examples).
139144
For a complete example of authorizing a PodSecurityPolicy, see
140145
[below](#example).
141146

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+
```
142180

143181
### Troubleshooting
144182

0 commit comments

Comments
 (0)