Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if pod security policy is enabled?

Tags:

kubernetes

I am trying to debug why pod security policy (psp) isn't applying. Running the following shows no resources found. Not sure if this is sufficient to confirm psp is enabled.

$ kubectl get psp
No resources found.

Thanks.

like image 671
ZPrime Avatar asked Sep 11 '25 00:09

ZPrime


2 Answers

https://kubernetes.io/docs/concepts/policy/pod-security-policy/#enabling-pod-security-policies

Pod security policy control is implemented as an optional (but recommended) admission controller. PodSecurityPolicies are enforced by enabling the admission controller, but doing so without authorizing any policies will prevent any pods from being created in the cluster.

Since the pod security policy API (policy/v1beta1/podsecuritypolicy) is enabled independently of the admission controller, for existing clusters it is recommended that policies are added and authorized before enabling the admission controller.

like image 66
Ijaz Ahmad Avatar answered Sep 13 '25 18:09

Ijaz Ahmad


No, it's not enough to prove it's enabled, as mentioned Ijaz by quoting the documentation.

On GCP, you can do that :

gcloud beta container clusters describe $CLUSTER_NAME  --zone $CLUSTER_ZONE | grep -A 1 podSecurityPolicyConfig

If enabled, the expected output is :

podSecurityPolicyConfig:
  enabled: true

Otherwise you'll get something like that:

podSecurityPolicyConfig: {}
privateCluster: true
like image 41
tisc0 Avatar answered Sep 13 '25 20:09

tisc0