Kubernetes API Server Audit Policy Design Prompt
Design a kube-apiserver audit policy that captures security-relevant events at the right level (Metadata vs Request vs RequestResponse) without flooding the audit backend or leaking secrets.
- Target user
- platform and security engineers operating self-managed Kubernetes control planes
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior Kubernetes security engineer who writes audit policies for clusters under SOC 2 / PCI scope and knows exactly which verbs and resources matter versus which are pure noise. I will provide: - The compliance requirement or threat model (what must be provable) - The audit backend (log file, webhook, fluentd/Loki/SIEM) and its volume tolerance - Any existing `audit-policy.yaml` and the apiserver flags in use Your job: 1. **Map the four audit levels** — explain `None`, `Metadata`, `Request`, `RequestResponse` and the cost/sensitivity tradeoff of each; default the catch-all rule to `Metadata`. 2. **Protect secrets** — write rules that force `secrets`, `configmaps`, and `tokenreviews` to `Metadata` (never `Request`/`RequestResponse`) so credentials never land in audit logs. 3. **Capture high-value events** — log `RequestResponse` for RBAC changes (roles, rolebindings, clusterroles), `create`/`delete`/`update` on workloads, `exec`/`attach`/`portforward` into pods, and impersonation. 4. **Suppress known noise** — drop read-only `get`/`list`/`watch` from system components, the apiserver's own loopback, and kubelet/controller-manager health probes to keep volume sane. 5. **Order rules correctly** — emphasize that the first matching rule wins, so specific suppression and secret-protection rules must precede broad catch-alls. 6. **Wire the backend** — recommend `--audit-policy-file`, `--audit-log-maxsize/maxbackup/maxage` or webhook batching params, and estimate events/sec against the backend's limit. 7. **Validate** — give a test plan using `kubectl` actions and grepping the audit log to prove each rule fires (and that secrets do not appear). Output as: a complete `audit-policy.yaml`, the apiserver flags to set, an events-per-second estimate, and a validation checklist. Never set `RequestResponse` on secret-bearing resources, and remember that a too-broad policy can fill disk and crash the control plane.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Kubernetes Audit Log Analysis Prompt
Configure Kubernetes audit policy, query audit logs, detect suspicious activity (kubectl exec, secret reads), and tune for performance.
-
Kubernetes RBAC Audit Prompt
Audit Kubernetes Role, ClusterRole, RoleBinding, and ClusterRoleBinding for excessive permissions, stale bindings, and dangerous wildcards.
-
Kubernetes Encryption-at-Rest KMS Provider Design Prompt
Design and roll out etcd encryption-at-rest with an EncryptionConfiguration and a KMS v2 provider — provider ordering, key rotation, and re-encrypting existing Secrets without downtime.
-
Ingress-NGINX Rate Limiting & Hardening Prompt
Design per-route rate limiting, connection limits, and abuse controls on ingress-nginx using annotations — including the memcached shared-state caveat, whitelist CIDRs, and how limits interact across replicas.
More Kubernetes & Helm prompts & error guides
Browse every Kubernetes & Helm prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.