Back to Security Guide

Pod Security Standards

Restricting Pod Privileges and Enforcing Security Policies

Pod Security Standards Overview

Pod Security Standards (PSS) define minimum security requirements for pods. They replace the deprecated Pod Security Policy (PSP) and provide built-in protection against common attack vectors like privilege escalation, unsafe capabilities, and unrestricted filesystem access.

💡 Key Insight: PSS provides three levels: Unrestricted, Baseline, and Restricted. Use Restricted for production workloads.

PSS Levels

1. Unrestricted

Allows all pod operations (default Kubernetes behavior):

2. Baseline

Prevents known privilege escalations:

3. Restricted

Enforces strict security standards:

Implementing PSS

Enforce at Namespace Level

apiVersion: v1 kind: Namespace metadata: name: production labels: pod-security.kubernetes.io/enforce: restricted pod-security.kubernetes.io/audit: restricted pod-security.kubernetes.io/warn: restricted

Restricted Pod Example

apiVersion: v1 kind: Pod metadata: name: secure-pod spec: serviceAccountName: restricted-account securityContext: runAsNonRoot: true runAsUser: 1000 fsGroup: 2000 seccompProfile: type: RuntimeDefault containers: - name: app image: myapp:latest securityContext: allowPrivilegeEscalation: false readOnlyRootFilesystem: true capabilities: drop: - ALL volumeMounts: - name: tmp mountPath: /tmp volumes: - name: tmp emptyDir: {}

Security Context Options

Setting Purpose
runAsNonRoot Requires containers to run as non-root user
allowPrivilegeEscalation Prevents privilege escalation via SUID
readOnlyRootFilesystem Prevents modifications to root filesystem
capabilities Controls Linux capabilities granted to container
seccompProfile Restricts system calls available to container

Best Practices

⚠️ Important: Some legacy applications may not work with Restricted PSS. Test thoroughly in Baseline mode first.

Troubleshooting PSS Issues

Pod Rejected by PSS

Solution: Check the pod's security context and adjust to meet the policy level

Application Won't Start

Solution: Check logs for capability or permission errors, adjust security context

Permission Denied Errors

Solution: Add temporary write volumes using emptyDir for application needs