TutorialNovember 18, 2026Sarah Kim1 views

Kubernetes Pod Security Standards: A Comprehensive Guide to Container Security Policies After PSP Deprecation

This guide presents methods for effectively managing container security policies in Kubernetes environments following the deprecation of Pod Security Policies (PSP). Through a practical guide leveraging Pod Security Standards (PSS) and Admission Controllers, it details key strategies required to build a secure and efficient Kubernetes security architecture.

#Kubernetes Security#Pod Security Standards#PSS#PSP Deprecation#Container Security#Admission Controller#OPA Gatekeeper#Kyverno#FRIIM CNAPP
Kubernetes Pod Security Standards: A Comprehensive Guide to Container Security Policies After PSP Deprecation
Sarah Kim

November 18, 2026

Kubernetes Pod Security Standards: A Comprehensive Guide to Container Security Policies After PSP Deprecation

Effectively managing Pod security policies in a Kubernetes environment is of paramount importance. Previously, Pod Security Policies (PSP) fulfilled this role; however, PSPs were deprecated starting with Kubernetes version 1.21 and completely removed in version 1.25. This change necessitated that many organizations seek new methods for security policy management. The complexity and management difficulties associated with PSPs further highlighted the need for a new approach. Kubernetes is now evolving towards strengthening container security through Pod Security Standards (PSS) and Admission Controller-based solutions that implement them.

This guide systematically addresses key strategies for managing Kubernetes security policies after PSP deprecation. From the concept of PSS to implementing and managing actual security policies using Policy Engines like OPA Gatekeeper, it provides practical insights through a step-by-step approach to further enhance the security level of container environments. This will serve as an essential guideline for building and operating a secure and robust Kubernetes cluster.

Background Knowledge: Limitations of PSP and the Emergence of PSS

First, let us examine why Pod Security Policies (PSP) were deprecated. PSP was an Admission Controller used to enforce specific security requirements for Pods in a Kubernetes cluster. For instance, it allowed defining policies such as prohibiting privileged container execution, restricting hostPath volume usage, and disallowing root user execution. However, PSP had several limitations, as outlined below.

  • Complex RBAC Bindings: PSPs were only applied if the correct PSP was bound to the Service Account requesting Pod creation. The necessary RBAC (Role-Based Access Control) configuration for this process was highly complex and prone to errors.
  • Difficulty with Granular Application: It was challenging to apply PSPs only to specific namespaces or to implement exceptions. This often led to strong policies being unintentionally applied to all Pods, causing operational difficulties.
  • Lack of Standard Baseline Policies: PSPs had to be defined directly based on security requirements, and there was a lack of a standardized method to establish a baseline security level for the cluster.

In summary, although PSPs provided powerful functionalities, a widespread understanding emerged that a better alternative was needed due to their management complexity and lack of application flexibility. Against this backdrop, Pod Security Standards (PSS) emerged. PSS simplifies the management of Kubernetes cluster security policies by providing three predefined security profiles.

  • Privileged: This policy has almost no restrictions and is used for infrastructure Pods that require broad access to the cluster and host.
  • Baseline: This policy applies minimal restrictions while preventing known privilege escalation attacks. It is suitable for most application Pods.
  • Restricted: This is a highly restrictive policy that adheres to Pod hardening best practices. It is used for the most security-sensitive application Pods.

PSS is applied by designating labels to Namespaces and is validated by the `PodSecurity` Admission Controller during Pod creation. This allows for easy management of security levels per Namespace without the complexity of RBAC bindings. Furthermore, by utilizing Policy Engines such as OPA Gatekeeper and Kyverno, more granular and flexible custom policies can be implemented in addition to the baseline PSS policies. In essence, PSS complements the shortcomings of PSPs and contributes to making Kubernetes security policy management more intuitive and efficient by providing standardized security guidelines.

Prerequisites

To follow this guide, the following environment and prior knowledge are required. First, a Kubernetes cluster is necessary. Using Kubernetes version 1.23 or higher is recommended, as this is the version where PSS began to be supported in General Availability (GA) status. The cluster can be in any form, such as Minikube or Kind in a local environment, or a managed service from a cloud provider (e.g., AWS EKS, Azure AKS, GCP GKE). Next, the `kubectl` command-line tool for interacting with the cluster must be installed and configured to access the target cluster.

Additionally, Helm must be installed. Helm is a package manager for Kubernetes applications and is used to easily deploy Policy Engines. Finally, a foundational understanding of Kubernetes concepts such as Pods, Deployments, Namespaces, and RBAC will facilitate a deeper comprehension of the guide's content. Fulfilling these prerequisites will enable a smooth progression through the practical exercises on Kubernetes security policy management using PSS and Policy Engines.

Environment Setup: Deploying OPA Gatekeeper

This section outlines the deployment of OPA Gatekeeper, a Policy Engine that implements and extends Pod Security Standards (PSS), to a Kubernetes cluster. OPA Gatekeeper is a framework that leverages Kubernetes Admission Controllers to enforce policies. First, Gatekeeper will be installed on the cluster using Helm. Gatekeeper is installed in a separate Namespace and monitors cluster-wide resources to apply policies.

The commands below can be used to add the Gatekeeper Helm Repository and install Gatekeeper into the `gatekeeper-system` Namespace. The installation commands are based on the latest version, and a specific version can be specified if required.


helm repo add gatekeeper https://open-policy-agent.github.io/gatekeeper/charts
helm repo update
kubectl create namespace gatekeeper-system
helm install gatekeeper gatekeeper/gatekeeper --namespace gatekeeper-system

The core objective of the above code is the rapid and stable deployment of Gatekeeper using Helm. Upon completion of the installation, it is necessary to verify that Gatekeeper's Pods are operating correctly. Execute the following command to check the status of Pods in the `gatekeeper-system` Namespace. All Pods should be in the `Running` state.


kubectl get pods -n gatekeeper-system

Gatekeeper is now activated as an Admission Controller for the cluster, ready to intercept Pod creation and update requests and validate them according to defined policies. The subsequent steps will detail how to apply PSS to Namespaces and implement custom policies through Gatekeeper.

Step-by-Step Guide: Implementing Security Policies with PSS and Gatekeeper

1. Applying Pod Security Standards (PSS) Labels

First, we will examine how to apply PSS to a specific Namespace. PSS is inherently enabled by the `PodSecurity` Admission Controller starting from Kubernetes 1.23. By merely adding appropriate labels to a Namespace, the PSS profile can be enforced for that Namespace. This guide will use the `restricted` profile as an example.

Create a test Namespace and apply the `restricted` PSS profile.


kubectl create namespace pss-test
kubectl label namespace pss-test 
    pod-security.kubernetes.io/enforce=restricted 
    pod-security.kubernetes.io/warn=restricted 
    pod-security.kubernetes.io/audit=restricted

Applying the above labels will enforce the `restricted` PSS in the `pss-test` Namespace, and warning (warn) and audit (audit) logs will be generated upon violations. If a Pod with a `privileged` container is now deployed in this Namespace, it will be denied by the PSS policy.

2. Creating a Gatekeeper ConstraintTemplate

Next, we will define custom security policies beyond PSS using OPA Gatekeeper. Gatekeeper implements policies through `ConstraintTemplate` and `Constraint` resources. A `ConstraintTemplate` is a CRD (Custom Resource Definition) that defines the logic of a policy, using the Rego language to write policy rules internally. Here, a `ConstraintTemplate` will be created to prohibit containers from running as the `root` user.

Create the disallow-root-user-template.yaml file:


apiVersion: templates.gatekeeper.sh/v1
kind: ConstraintTemplate
metadata:
  name: k8sdisallowrootuser
spec:
  crd:
    spec:
      names:
        kind: K8sDisallowRootUser
  targets:
    - target: admission.k8s.gatekeeper.sh
      rego:
        package: k8sdisallowrootuser
        # Rego 정책 정의: 컨테이너가 root 유저(UID 0)로 실행되는 것을 금지합니다.
        # runAsNonRoot가 true로 설정되어 있거나, runAsUser가 0이 아닌 경우에만 허용합니다.
        # 보안 컨텍스트가 설정되지 않은 경우에도 거부합니다.
        violation[{"msg": msg}] {
          container := input.review.object.spec.containers[i]
          not container.securityContext.runAsNonRoot == true
          not container.securityContext.runAsUser > 0 # Allow non-zero UID
          msg := sprintf("Container '%v' must not run as root. Set runAsNonRoot to true or runAsUser to a non-zero value.", [container.name])
        }
        violation[{"msg": msg}] {
          container := input.review.object.spec.initContainers[i]
          not container.securityContext.runAsNonRoot == true
          not container.securityContext.runAsUser > 0
          msg := sprintf("Init Container '%v' must not run as root. Set runAsNonRoot to true or runAsUser to a non-zero value.", [container.name])
        }

Apply the above YAML file to the cluster. This ConstraintTemplate considers it a violation if a container is not configured with `runAsNonRoot: true` or `runAsUser` set to a value greater than 0.


kubectl apply -f disallow-root-user-template.yaml

3. Creating a Gatekeeper Constraint

Now, a `Constraint` will be created to apply the defined `ConstraintTemplate` to a real Namespace. A `Constraint` specifies which resources (e.g., Pods), which `ConstraintTemplate`, and which parameters to apply. Here, the previously created `K8sDisallowRootUser` template will be applied to the `pss-test` Namespace.

Create the disallow-root-user-constraint.yaml file:


apiVersion: constraints.gatekeeper.sh/v1beta1
kind: K8sDisallowRootUser
metadata:
  name: disallow-root-user-in-pss-test
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces:
      - "pss-test" # pss-test 네임스페이스에만 이 정책을 적용합니다.

Apply the above YAML file to the cluster.


kubectl apply -f disallow-root-user-constraint.yaml

When deploying Pods to the `pss-test` Namespace, both the PSS `restricted` profile and the policy prohibiting root user execution will be applied. A key aspect of `Constraint` is the ability to clearly define the policy's scope of application via `match.namespaces`.

4. Policy Testing and Verification of Results

Now, the defined policies will be tested to ensure proper functionality. A Pod that violates both the PSS `restricted` and Gatekeeper `K8sDisallowRootUser` policies will be deployed to the `pss-test` Namespace. A Pod including `privileged: true` and `runAsUser: 0` will be created.

Create the bad-pod.yaml file:


apiVersion: v1
kind: Pod
metadata:
  name: bad-security-pod
  namespace: pss-test
spec:
  containers:
    - name: bad-container
      image: busybox
      command: ["sleep", "3600"]
      securityContext:
        privileged: true # PSS restricted 위반
        runAsUser: 0     # Gatekeeper 정책 위반 (root 유저)

Attempt to deploy this Pod.


kubectl apply -f bad-pod.yaml

Upon executing the command, the Pod creation request will be denied. The denial message can be verified using the `kubectl describe pod bad-security-pod -n pss-test` command, confirming that both PSS and Gatekeeper policies have been applied.

Expected Outcomes

If the environment has been successfully configured and policies deployed according to the preceding step-by-step guide, the following outcomes can be anticipated. First, after applying labels to the `pss-test` Namespace, deploying a Pod that violates the PSS `restricted` profile (e.g., `privileged: true`) to that Namespace will result in the Pod creation request being denied by the Kubernetes API server's `PodSecurity` Admission Controller. The error message will include content such as `pods "bad-security-pod" is forbidden: violates PodSecurity "restricted:latest"`, clearly indicating a PSS violation.

Similarly, after applying the `K8sDisallowRootUser` ConstraintTemplate and Constraint created via OPA Gatekeeper, deploying a Pod configured with `runAsUser: 0` to the `pss-test` Namespace will lead to Pod creation being denied by the Gatekeeper Admission Controller. In this instance, the error message will contain details of the policy violation as defined by Gatekeeper. For example, a message such as `Admission webhook "validation.gatekeeper.sh" denied the request: [k8sdisallowrootuser] Container 'bad-container' must not run as root.` can be observed. These two outcomes demonstrate that PSS and Gatekeeper-based custom policies are successfully operating within the cluster and validating the security attributes of Pods.

Troubleshooting

Several common issues may arise during the process of configuring and managing Kubernetes security policies. This section will examine troubleshooting methods for each issue.

1. Gatekeeper Pods Not in Running State

After installing Gatekeeper, executing `kubectl get pods -n gatekeeper-system` may show Pods in `Pending` or `CrashLoopBackOff` states. This typically occurs due to resource starvation, Custom Resource Definition (CRD) installation errors, or network issues.

  • Solution: Identify the specific cause by checking the event logs with the command `kubectl describe pod <gatekeeper-pod-name> -n gatekeeper-system`. If resource starvation is the issue, increase the cluster's resource quotas or adjust the Gatekeeper Pod's resource requests. If CRDs were not installed correctly, one might try running the Helm command with `helm install --skip-crds` and then manually applying the CRDs.

2. Policies Not Applied or Behaving Unexpectedly

Instances may occur where a policy-violating Pod is not denied after deployment, or an unintended Pod is denied.

  • Solution:
    • Verify Namespace Labels: For PSS, ensure that the `pod-security.kubernetes.io/enforce` label is correctly applied to the target Namespace.
    • Check Constraint/ConstraintTemplate Scope: Confirm that the `match.namespaces` or `match.kinds` in the Gatekeeper Constraint are correctly configured.
    • Review Rego Policy: Re-examine the Rego policy logic within the ConstraintTemplate for correctness. Gatekeeper's Audit mode can be utilized to check if current cluster resources violate defined policies.
    • Verify Admission Controller Status: Confirm whether the `PodSecurity` Admission Controller is enabled on the Kubernetes API server and if the Gatekeeper webhook is properly registered.

3. Admission Webhook Timeout Occurs

This issue arises when an error such as `Admission webhook "validation.gatekeeper.sh" denied the request: timed out` occurs during Pod creation. This is typically caused by delayed responses from Gatekeeper Pods or network latency.

  • Solution: Allocate sufficient resources (CPU, Memory) to Gatekeeper Pods to resolve performance bottlenecks. Additionally, confirm that there is no network latency between Gatekeeper Pods and the API server, and adjust Service Mesh or network policies if necessary. Increasing the `timeoutSeconds` value in Gatekeeper's `ValidatingWebhookConfiguration` can serve as a temporary workaround, but fundamental performance improvements should be prioritized.

These troubleshooting tips can effectively assist in diagnosing and resolving common failures that may occur during Kubernetes security policy management.

Advanced Use Cases

Security policy management utilizing Pod Security Standards (PSS) and Policy Engines can extend beyond basic applications to various advanced scenarios. These advanced applications can further enhance the robustness and efficiency of the security architecture.

1. CI/CD Pipeline Integration

Beyond detecting policy violations at runtime, it is efficient to validate policies from the early stages of development. Adding a policy validation step to the CI/CD pipeline enables checking for policy violations before Kubernetes manifests are deployed to the cluster. Policy validation can be performed in a Dry Run manner in local environments or CI/CD pipelines using OPA Gatekeeper's `gator` CLI tool or the Kyverno CLI tool. This allows developers to identify and rectify potential security issues early, thereby reducing bottlenecks in the development process prior to deployment.

2. GitOps and Policy Management

PSS labels and Gatekeeper/Kyverno policies can be managed as code in a Git Repository by leveraging GitOps tools such as ArgoCD or FluxCD. The Policy as Code (PaC) approach enables tracking, reviewing, and automatically applying all policy changes to the cluster via Git. This significantly enhances consistency, transparency, and automation in policy management. It is possible to ensure the stability of policy deployments by utilizing the Sync and Health Check functionalities of GitOps tools.

3. Utilizing Audit Mode and Monitoring

Before applying new policies to a cluster in `enforce` mode, deploying them first in `audit` or `warn` mode allows for measuring their impact on the actual environment and pre-identifying potential issues. Gatekeeper can scan existing resources to determine how extensively they violate defined policies through its Audit function. These audit results can be integrated with monitoring stacks such as Prometheus and Grafana to visualize policy violation statuses and establish a continuous monitoring system. It is advisable to establish an automated response system that immediately notifies security teams via alerting systems like Slack or PagerDuty when violations are detected.

4. Dynamic Parameters and Mutating Policies

Gatekeeper can receive dynamic parameters in a ConstraintTemplate to increase policy flexibility. For example, policies can be created that only allow specific image registries by accepting a list of registries as a parameter. Kyverno also offers the capability to modify (mutate) a Pod's Manifest, in addition to simply denying Pods during policy application. For instance, it can automatically inject settings like `runAsNonRoot: true` into Pods without a security context, thereby enforcing security defaults. Such Mutating Webhook policies serve as powerful tools that enhance developer convenience while fulfilling security requirements.

By leveraging PSS and Policy Engines at an advanced level, organizations can establish a foundation for more robust and flexible security management in Kubernetes environments.

Security Considerations

When implementing security policies using Kubernetes Pod Security Standards and Policy Engines, several important security considerations must be kept in mind. These considerations are essential for strengthening the overall security posture of the cluster and minimizing potential risks.

  • Principle of Least Privilege: All security policies must be designed according to the principle of least privilege. Pods should possess only the minimum permissions necessary to perform their designated tasks. Policies that permit overly broad privileges can increase potential attack vectors.
  • Thorough Policy Testing: Before applying new security policies in `enforce` mode to a production environment, comprehensive testing must be conducted in development and staging environments. This prevents malfunctioning policies from disrupting the normal deployment and operation of applications. Policy validity should be verified by considering various scenarios and edge cases.
  • Regular Policy Review and Updates: Cluster usage patterns, application requirements, and the latest security threat trends are constantly evolving. Consequently, security policies must be regularly reviewed and updated to align with these changes. Outdated policies may fail to defend against new vulnerabilities.
  • Establish `break-glass` Procedures: In preparation for emergency situations or policy errors that could halt cluster operations, `break-glass` procedures must be established to temporarily disable or bypass defined policies. These procedures must be strictly controlled, thoroughly documented, and access privileges granted to a minimal number of personnel.
  • Logging and Monitoring: Policy violation logs from Admission Controllers and Audit logs from Policy Engines should be continuously collected and monitored. It is crucial to establish a system capable of detecting anomalies or repeated policy violation attempts and responding immediately. This ensures visibility into security events and enables prompt action.

By strictly adhering to these security considerations, organizations can effectively operate Pod Security Standards and Policy Engine-based security policies in Kubernetes environments and continuously improve the overall security posture of their clusters.

Conclusion

The deprecation of Pod Security Policies (PSP) in Kubernetes environments necessitated a new approach to container security policy management. This guide provided a step-by-step examination of understanding the background for PSS introduction, the importance of its three security profiles, and how to implement more robust and flexible custom security policies by complementing PSS with Policy Engines like OPA Gatekeeper. The standardized, Namespace-based security application through PSS and granular policy control via Policy Engines can be considered essential strategies for elevating the security level of Kubernetes clusters.

In summary, effective Kubernetes security policy management is underpinned by PSS, with the concurrent use of Policy Engines such as OPA Gatekeeper or Kyverno to implement and enforce policies tailored to an organization's specific requirements. A comprehensive approach is crucial, encompassing policy validation during the early development stages, GitOps-based policy management, and continuous monitoring. Such systematic security policy management will significantly assist in protecting clusters and applications from potential security threats and meeting compliance requirements. Essentially, it becomes a key factor for minimizing security vulnerabilities and ensuring stable operations in containerized environments.

For subsequent learning, it is recommended to master more complex Rego policy writing or explore Kyverno's mutating and validating policy features to implement more sophisticated security automation. Furthermore, organizations can explore methods to reduce the complexity and maximize the efficiency of Kubernetes security policy management through integrated solutions such as Cloud-Native Application Protection Platforms (CNAPP). Specifically, FRIIM CNAPP can streamline and enhance these processes by automating Pod Security Standards and Policy Engine-based policy management, while comprehensively providing cloud-wide security visibility and compliance adherence. Utilizing FRIIM CNAPP enables security operations teams to reduce their burden across the entire process—from policy definition and application to monitoring and violation response—and effectively maintain the security posture of cloud environments.

Stay Updated

Get the latest security insights delivered to your inbox.

Tags

#Kubernetes Security#Pod Security Standards#PSS#PSP Deprecation#Container Security#Admission Controller#OPA Gatekeeper#Kyverno#FRIIM CNAPP