Pod Security Policies

The kube guy
3 min readNov 13, 2023

This article is part of kubernetes security series, If you wish to recieve such articles, do follow The kube guy

Welcome to Kubernetes Security series, Today let’s learn about Pod Security Policies. These policies are nothing but rules which specify how the pod should function or act. Let’s not waste any more time and dig into the topic.

Understanding the Basics

Before delving into Pod Security Policies, let’s start with some foundational concepts. Kubernetes is an open-source container orchestration platform that simplifies container deployment and management. Pods are the smallest deployable units in Kubernetes and can contain one or more containers.

What Are Pod Security Policies?

Pod Security Policies (PSPs) are a set of rules that specify how a pod should run. They provide a way to control various aspects of pod security, such as which users and groups can run pods, which host namespaces a pod can access, and the usage of privileged containers.

PSPs are a form of admission control in Kubernetes, which means they are evaluated when a pod is created. If a pod does not meet the criteria specified in the PSP, it will not be allowed to run, providing an essential layer of security.

Real-World Examples

Let’s walk through a couple of real-world scenarios to understand how PSPs work.

Scenario 1: Restricting Host Network Access

Suppose you have an application that should not be able to access the host network. You can create a PSP that restricts any pod from using the host network namespace. Here’s an example configuration:

apiVersion: policy/v1beta1
kind: PodSecurityPolicy
name: restrict-host-network
hostNetwork: false
# Add other restrictions as needed

When you apply this policy, any pod attempting to use the host network will be denied.

Scenario 2: Disallowing Privileged Containers

A privileged container can access all devices on the host, which poses significant security risks. You can create a PSP to disallow privileged containers:

apiVersion: policy/v1beta1
kind: PodSecurityPolicy
name: disallow-privileged-containers
privileged: false
# Add other restrictions as needed

Any pod attempting to run a privileged container will be prevented by this policy.

These examples showcase how you can use PSPs to enforce security controls tailored to your application’s needs.

Benefits and Best Practices

By implementing Pod Security Policies, you gain several advantages. You can:

  • Ensure that your pods run securely and adhere to your organization’s security policies.
  • Mitigate the risks associated with misconfigured or malicious pods.
  • Improve compliance with industry security standards.

To get the most out of PSPs, consider these best practices:

  • Start with minimal policies and incrementally tighten security as needed.
  • Regularly review and update your PSPs to adapt to changing security requirements.
  • Test your policies thoroughly to ensure they don’t disrupt the operation of legitimate pods.


Pod Security Policies are a powerful tool in your Kubernetes security toolbox. By creating and applying them effectively, you can enforce security controls and ensure that your containerized applications run securely. As a beginner, you’ve taken the first step in understanding PSPs, and with practice, you’ll become proficient in securing your Kubernetes environment.

For further exploration, refer to the official Kubernetes documentation on Pod Security Policies and consider other security measures that can complement PSPs in your Kubernetes cluster. Your journey to a more secure Kubernetes environment has just begun!

I hope you find this blog informative and helpful. If you have any questions or require further assistance, please don’t hesitate to ask.



The kube guy

I'll help you sail through the ocean of Kubernetes with minimal efforts