惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
MyScale Blog
MyScale Blog
Y
Y Combinator Blog
罗磊的独立博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
P
Proofpoint News Feed
Google DeepMind News
Google DeepMind News
V
Vulnerabilities – Threatpost
T
The Blog of Author Tim Ferriss
云风的 BLOG
云风的 BLOG
Recorded Future
Recorded Future
N
News and Events Feed by Topic
B
Blog RSS Feed
阮一峰的网络日志
阮一峰的网络日志
博客园_首页
C
CXSECURITY Database RSS Feed - CXSecurity.com
博客园 - 【当耐特】
N
Netflix TechBlog - Medium
博客园 - 叶小钗
B
Blog
Vercel News
Vercel News
T
Tenable Blog
T
The Exploit Database - CXSecurity.com
Spread Privacy
Spread Privacy
T
Threat Research - Cisco Blogs
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Last Week in AI
Last Week in AI
F
Fortinet All Blogs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Microsoft Security Blog
Microsoft Security Blog
S
Securelist
Microsoft Azure Blog
Microsoft Azure Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Palo Alto Networks Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
D
DataBreaches.Net
Cyberwarzone
Cyberwarzone
Engineering at Meta
Engineering at Meta
Martin Fowler
Martin Fowler
G
GRAHAM CLULEY
Project Zero
Project Zero
Cisco Talos Blog
Cisco Talos Blog
A
Arctic Wolf
C
CERT Recently Published Vulnerability Notes
L
LangChain Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
C
Check Point Blog
A
About on SuperTechFans
W
WeLiveSecurity
The GitHub Blog
The GitHub Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Configure Audit Logging in Kubernetes
josepraveen · 2026-05-31 · via DEV Community

josepraveen

Picture this: Your team just wrapped up a security incident simulation. The dust settles, and you huddle up for the postmortem. You ask, "Who modified that deployment?" or "What exact payload was sent to the API?" The room goes silent. You check the logs, only to realize there are no logs of what was done via the Kubernetes API.

Without audit logging, your cluster is essentially a black box. To fix this blind spot, we are going to look at how to implement robust audit policy rules and configure the Kubernetes API server to track threats both in real-time and postmortem.


🧠 Understanding the 4 Audit Levels

Before diving into config files, you need to understand the four Audit Levels in Kubernetes. They dictate the depth of data you collect (and how fast your storage will fill up!):

  • None: Don't log this event at all.
  • Metadata: Log the basics only (who did it, when, from where, and to what resource). It excludes the request and response bodies.
  • Request: Log the Metadata + the exact content/payload sent to the cluster.
  • RequestResponse: Log Metadata + the Request content + the exact response returned by the cluster. This provides total visibility but generates massive amounts of data.

🛠️ Step 1: Crafting the Audit Policy Rules

Let's configure a smart, security-first audit policy. Open your audit policy file:

sudo vi /etc/kubernetes/audit-policy.yaml

Enter fullscreen mode Exit fullscreen mode

Paste the following YAML configuration. This policy is highly optimized to balance deep visibility, disk space saving, and credential security:

# 1. Log request and response bodies for all changes to Namespaces.

  • level: RequestResponse resources:
    • group: "" resources: ["namespaces"]

# 2. Log request bodies (but not response bodies) for changes to Pods and Services in the 'web' Namespace.

  • level: Request resources:
    • group: "" resources: ["pods", "services"] namespaces: ["web"]

# 3. Log metadata ONLY for all changes to Secrets.

  • level: Metadata resources:
    • group: "" resources: ["secrets"]

# 4. Create a catch-all rule to log metadata for all other requests.

  • level: Metadata

💡 Why did we set it up this way?

  • Namespaces (RequestResponse): Creating or deleting a namespace is a major structural change. We want maximum data to see exactly who requested it and what the cluster returned.
  • Pods & Services (Request): These resources change constantly. Logging the full response bodies would fill up your disks rapidly. Request ensures you see what a user tried to do while saving storage.
  • Secrets (Metadata): Crucial security practice! If you use Request or RequestResponse here, your plain-text passwords and sensitive TLS keys will be written directly into your log files. Metadata captures who touched the secret without leaking the secret data itself.
  • The Catch-all (Metadata): Ensures that if someone modifies something else (like a Deployment or ConfigMap), we still capture the baseline who, what, and when.

Save and exit the file (Esc, then :wq, then Enter).

audit policy


⚙️ Step 2: Configuring the API Server

The API Server (kube-apiserver) is the brain of your control plane. Every single command runs through it. To activate our new policy, we need to pass these rules to it.

Open the static pod manifest for the API server:

sudo vi /etc/kubernetes/manifests/kube-apiserver.yaml

Enter fullscreen mode Exit fullscreen mode

Under the - command arguments block, append the following flags:

- command:
  - kube-apiserver
  # ... existing flags ...
  - --audit-policy-file=/etc/kubernetes/audit-policy.yaml
  - --audit-log-path=/var/log/kubernetes/k8s-audit.log
  - --audit-log-maxage=60
  - --audit-log-maxbackup=1

Enter fullscreen mode Exit fullscreen mode

Breakdown of the flags:

  • --audit-policy-file: Tells the API Server where to find the rules we wrote in Step 1.
  • --audit-log-path: Specifies the exact file path on the master node where the JSON logs will be written.
  • --audit-log-maxage=60: Automatically retains old log files for a maximum of 60 days.
  • --audit-log-maxbackup=1: Restricts log rotation to keep only 1 archived backup file, preventing out-of-disk crashes.

Save and exit the file.

kubeapiserver

Because this is a static pod, the kube-apiserver will automatically restart to apply the changes. Give it a minute, then verify the cluster is healthy:

kubectl get nodes

Enter fullscreen mode Exit fullscreen mode


🧪 Step 3: Testing the Setup

Let's test our security guardrails by creating a dummy secret and seeing how it logs.

kubectl create secret generic my-secret --from-literal=password=SuperSecret123

Enter fullscreen mode Exit fullscreen mode

Now, check the audit log file:

sudo tail -f /var/log/kubernetes/k8s-audit.log

Enter fullscreen mode Exit fullscreen mode

audit log

Look closely at the JSON block generated for my-secret. Because of our Metadata rule, you will see a trail showing that a secret was created, but you will not see SuperSecret123 anywhere in the logs.


🔑 Key Takeaways

  1. Always implement a Catch-all rule at the end of your policy so nothing slips through.
  2. Never log Request or RequestResponse on Secrets.
  3. Manage your log sizes aggressively using --audit-log-maxage and --audit-log-maxbackup.