Configure securityContext and Pod Security Admission to enforce restricted pod standards

domain: kubernetes.io · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Label the namespace with `pod-security.kubernetes.io/enforce: restricted` and optionally `warn` and `audit` at the same or lower level
  2. Set `spec.securityContext.runAsNonRoot: true` and `runAsUser` to a non-zero UID in Pod or Deployment specs
  3. Set `spec.containers[].securityContext.allowPrivilegeEscalation: false` and `readOnlyRootFilesystem: true` on each container
  4. Set `capabilities.drop: [ALL]` and add back only the specific Linux capabilities required (e.g., `NET_BIND_SERVICE`)
  5. Apply in `warn` mode first and review warning output from `kubectl apply` before switching to `enforce`

Known gotchas

Related routes

Configure a Kubernetes admission webhook with cert-manager for TLS provisioning and implement a ValidatingWebhookConfiguration to enforce custom policies
kubernetes.io · 5 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans