|
| 1 | +--- |
| 2 | +layout: blog |
| 3 | +title: "Kubernetes v1.25: Pod Security Admission Controller in Stable" |
| 4 | +date: 2022-08-25 |
| 5 | +slug: pod-security-admission-stable |
| 6 | +--- |
| 7 | + |
| 8 | +**Authors:** Tim Allclair (Google), Sam Stoelinga (Google) |
| 9 | + |
| 10 | +The release of Kubernetes v1.25 marks a major milestone for Kubernetes out-of-the-box pod security |
| 11 | +controls: Pod Security admission (PSA) graduated to stable, and Pod Security Policy (PSP) has been |
| 12 | +removed. |
| 13 | +[PSP was deprecated in Kubernetes v1.21](https://kubernetes.io/blog/2021/04/06/podsecuritypolicy-deprecation-past-present-and-future/), |
| 14 | +and no longer functions in Kubernetes v1.25 and later. |
| 15 | + |
| 16 | +The Pod Security admission controller replaces PodSecurityPolicy, making it easier to enforce predefined |
| 17 | +[Pod Security Standards](https://kubernetes.io/docs/concepts/security/pod-security-standards/) by |
| 18 | +simply adding a label to a namespace. The Pod Security Standards are maintained by the K8s |
| 19 | +community, which means you automatically get updated security policies whenever new |
| 20 | +security-impacting Kubernetes features are introduced. |
| 21 | + |
| 22 | + |
| 23 | +## What’s new since Beta? |
| 24 | + |
| 25 | +Pod Security Admission hasn’t changed much since the Beta in Kubernetes v1.23. The focus has been on |
| 26 | +improving the user experience, while continuing to maintain a high quality bar. |
| 27 | + |
| 28 | +### Improved violation messages |
| 29 | + |
| 30 | +We improved violation messages so that you get |
| 31 | +[fewer duplicate messages](https://github.com/kubernetes/kubernetes/pull/107698). For example, |
| 32 | +instead of the following message when the Baseline and Restricted policies check the same |
| 33 | +capability: |
| 34 | + |
| 35 | +``` |
| 36 | +pods "admin-pod" is forbidden: violates PodSecurity "restricted:latest": non-default capabilities (container "admin" must not include "SYS_ADMIN" in securityContext.capabilities.add), unrestricted capabilities (container "admin" must not include "SYS_ADMIN" in securityContext.capabilities.add) |
| 37 | +``` |
| 38 | + |
| 39 | +You get this message: |
| 40 | + |
| 41 | +``` |
| 42 | +pods "admin-pod" is forbidden: violates PodSecurity "restricted:latest": unrestricted capabilities (container "admin" must not include "SYS_ADMIN" in securityContext.capabilities.add) |
| 43 | +``` |
| 44 | + |
| 45 | +### Improved namespace warnings |
| 46 | + |
| 47 | +When you modify the `enforce` Pod Security labels on a namespace, the Pod Security |
| 48 | +admission controller checks all existing pods for |
| 49 | +violations and surfaces a [warning](/blog/2020/09/03/warnings/) if any are out of compliance. These |
| 50 | +[warnings are now aggregated](https://github.com/kubernetes/kubernetes/pull/105889) for pods with |
| 51 | +identical violations, making large namespaces with many replicas much more manageable. For example: |
| 52 | + |
| 53 | +``` |
| 54 | +Warning: frontend-h23gf2: allowPrivilegeEscalation != false |
| 55 | +Warning: myjob-g342hj (and 6 other pods): host namespaces, allowPrivilegeEscalation != false Warning: backend-j23h42 (and 1 other pod): non-default capabilities, unrestricted capabilities |
| 56 | +``` |
| 57 | + |
| 58 | +Additionally, when you apply a non-privileged label to a namespace that has been |
| 59 | +[configured to be exempt](https://kubernetes.io/docs/concepts/security/pod-security-admission/#exemptions), |
| 60 | +you will now get a warning alerting you to this fact: |
| 61 | + |
| 62 | +``` |
| 63 | +Warning: namespace 'kube-system' is exempt from Pod Security, and the policy (enforce=baseline:latest) will be ignored |
| 64 | +``` |
| 65 | + |
| 66 | +### Changes to the Pod Security Standards |
| 67 | + |
| 68 | +The [Pod Security Standards](https://kubernetes.io/docs/concepts/security/pod-security-standards/), |
| 69 | +which Pod Security admission enforces, have been updated with support for the new Pod OS |
| 70 | +field. In v1.25 and later, if you use the Restricted policy, the following Linux-specific restrictions will no |
| 71 | +longer be required if you explicitly set the pod's `.spec.os.name` field to `windows`: |
| 72 | + |
| 73 | +* Seccomp - The `seccompProfile.type` field for Pod and container security contexts |
| 74 | +* Privilege escalation - The `allowPrivilegeEscalation` field on container security contexts |
| 75 | +* Capabilities - The requirement to drop `ALL` capabilities in the `capabilities` field on containers |
| 76 | + |
| 77 | +In Kubernetes v1.23 and earlier, the kubelet didn't enforce the Pod OS field. |
| 78 | +If your cluster includes nodes running a v1.23 or older kubelet, you should explicitly |
| 79 | +[pin Restricted policies](https://kubernetes.io/docs/concepts/security/pod-security-admission/#pod-security-admission-labels-for-namespaces) |
| 80 | +to a version prior to v1.25. |
| 81 | + |
| 82 | +## Migrating from PodSecurityPolicy to the Pod Security admission controller |
| 83 | + |
| 84 | +For instructions to migrate from PodSecurityPolicy to the Pod Security admission controller, and |
| 85 | +for help choosing a migration strategy, refer to the |
| 86 | +[migration guide](https://kubernetes.io/docs/tasks/configure-pod-container/migrate-from-psp/). |
| 87 | +We're also developing a tool called |
| 88 | +[pspmigrator](https://github.com/kubernetes-sigs/pspmigrator) to automate parts |
| 89 | +of the migration process. |
| 90 | + |
| 91 | +We'll be talking about PSP migration in more detail at our upcoming KubeCon 2022 NA talk, |
| 92 | +[*Migrating from Pod Security Policy*](https://sched.co/182Jx). Use the |
| 93 | +[KubeCon NA schedule](https://events.linuxfoundation.org/kubecon-cloudnativecon-north-america/program/schedule/) |
| 94 | +to learn more. |
0 commit comments