Restricted Profile — heavily restricted pod security standard.
1apiVersion: v12kind: Namespace3metadata:4 name: restricted-ns5 labels:6 pod-security.kubernetes.io/enforce: restricted7 pod-security.kubernetes.io/enforce-version: latest8---9# Compliant Pod (restricted)10apiVersion: v111kind: Pod12metadata:13 name: restricted-pod14 namespace: restricted-ns15spec:16 securityContext:17 runAsNonRoot: true18 runAsUser: 100019 runAsGroup: 100020 fsGroup: 100021 seccompProfile:22 type: RuntimeDefault23 containers:24 - name: app25 image: nginx:latest26 securityContext:27 allowPrivilegeEscalation: false28 capabilities:29 drop:30 - ALL31 runAsNonRoot: true32 volumeMounts:33 - name: tmp34 mountPath: /tmp35 volumes:36 - name: tmp37 emptyDir: {}
1# Commands2kubectl get namespace restricted-ns -o yaml | grep pod-security34# Test restricted compliance5kubectl apply -f restricted-pod.yaml # Should succeed67# View violations8kubectl apply -f non-compliant-pod.yaml 2>&1910# Check Pod security context11kubectl get pod restricted-pod -o jsonpath='{.spec.securityContext}' | jq12kubectl get pod restricted-pod -o jsonpath='{.spec.containers[0].securityContext}' | jq1314# Verify non-root15kubectl exec restricted-pod -- id16kubectl exec restricted-pod -- whoami1718# Check seccomp profile19kubectl exec restricted-pod -- cat /proc/1/status | grep Seccomp
Restricted Disallows:
Required: