Description
On a legacy cluster, creating a PodSecurityPolicy (PSP) does not enforce it while the admission plugin is disabled. Kubernetes deprecated PSP in 1.21 and removed it in 1.25.
Potential impact
Missing restrictions may permit privileged execution or host access. Conversely, enabling PSP without an applicable policy or permission to use it can block required Pods.
Remediation
On a cluster still using PSP, prepare the policies and grant the minimum use permissions before enabling the plugin. When moving to a supported version, enforce the required restrictions with Pod Security Admission or another supported policy. Test that approved workloads deploy and disallowed Pod settings are rejected.
Examples
These excerpts compare plugin arguments for the unsupported Kubernetes 1.24.17 release. They omit the policies, permissions and remaining control-plane configuration, including certificates and storage.
Before
apiVersion: v1
kind: Pod
metadata:
name: api-server
spec:
containers:
- name: kube-apiserver
image: registry.k8s.io/kube-apiserver:v1.24.17
command:
- "kube-apiserver"
args:
- "--disable-admission-plugins=PodSecurityPolicy"
After
apiVersion: v1
kind: Pod
metadata:
name: api-server
spec:
containers:
- name: kube-apiserver
image: registry.k8s.io/kube-apiserver:v1.24.17
command:
- "kube-apiserver"
args:
- "--enable-admission-plugins=PodSecurityPolicy"