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

推荐订阅源

T
Tenable Blog
月光博客
月光博客
雷峰网
雷峰网
WordPress大学
WordPress大学
博客园 - 司徒正美
Last Week in AI
Last Week in AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
Visual Studio Blog
H
Help Net Security
Engineering at Meta
Engineering at Meta
Google DeepMind News
Google DeepMind News
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security @ Cisco Blogs
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
爱范儿
爱范儿
W
WeLiveSecurity
J
Java Code Geeks
Forbes - Security
Forbes - Security
H
Hacker News: Front Page
T
Threatpost
The Cloudflare Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
N
Netflix TechBlog - Medium
Latest news
Latest news
V2EX - 技术
V2EX - 技术
小众软件
小众软件
T
The Blog of Author Tim Ferriss
A
Arctic Wolf
B
Blog RSS Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
I
InfoQ
C
Check Point Blog
N
News | PayPal Newsroom
Cyberwarzone
Cyberwarzone
V
V2EX
TaoSecurity Blog
TaoSecurity Blog
P
Privacy & Cybersecurity Law Blog
Microsoft Security Blog
Microsoft Security Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
D
DataBreaches.Net
F
Fortinet All Blogs
阮一峰的网络日志
阮一峰的网络日志
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
IT之家
IT之家
K
Kaspersky official blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Google DeepMind News
Google DeepMind News
C
CXSECURITY Database RSS Feed - CXSecurity.com
www.infosecurity-magazine.com
www.infosecurity-magazine.com

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
Kubernetes Network Policies Cut Egress Bills, Not Just Attack Surface
Muskan · 2026-05-08 · via DEV Community

Muskan

Most teams add NetworkPolicy to their Kubernetes clusters for security reasons. They want microsegmentation. They want blast radius control. Cost is not part of the conversation.

That is a mistake. Unrestricted pod egress is a direct line to NAT Gateway data processing charges, cross-AZ transfer fees, and surprise line items on your AWS bill. NetworkPolicy is both a security control and a cost control. Teams that treat it as only one of those leave real money on the table.

The NAT Gateway Tax Nobody Talks About

AWS charges $0.045 per GB for every byte that passes through a NAT Gateway. That is on top of $0.045 per hour just to keep the gateway running: $32.40/month before a single byte of traffic.

In a cluster without egress NetworkPolicy, every pod that makes an outbound call to an external API, package registry, or telemetry endpoint runs that traffic through NAT. A cluster with 50 workloads, each pulling 100 MB of dependency updates daily, generates 150 GB/month of NAT-processed data. At $0.045/GB, that is $6.75/month on updates alone. Add application telemetry, health check pings to external endpoints, and log shipping, and that number climbs fast.

The real compounding happens at scale. Teams deploy new workloads each sprint. Each workload gets a default-open pod spec. Nobody audits what it calls externally. Six months later, NAT Gateway data processing is a $400/month line item that nobody owns.

NAT Gateway egress flow

Cross-AZ traffic compounds the problem further. AWS charges $0.01 per GB in each direction for data crossing availability zones. A pod in us-east-1a calling a service deployed in us-east-1b pays $0.02/GB round-trip. Without topology-aware routing and without NetworkPolicy guiding traffic to local endpoints, that charge accumulates invisibly alongside the NAT costs.

Why Kubernetes Defaults Are Wide Open

Kubernetes ships with a default-allow networking model. Every pod can reach every other pod and every external endpoint unless something explicitly restricts it. That is not a bug. It is a deliberate design choice to make getting started easy. But "easy to start" and "safe to run at scale" are different requirements.

NetworkPolicy objects define ingress and egress rules for pods. They are namespace-scoped, and they only take effect when your CNI plugin supports enforcement. This is the part most documentation glosses over: the policy object is not enough. You need a policy-aware CNI.

The default AWS VPC CNI (aws-node) does not enforce NetworkPolicy natively. You must install either the AWS Network Policy Controller addon (available in EKS 1.25+), Calico deployed as a standalone policy engine alongside aws-node, or Cilium replacing aws-node entirely with an eBPF-based dataplane.

On GKE, NetworkPolicy enforcement requires enabling the --enable-network-policy flag at cluster creation or upgrading to Dataplane V2 (Cilium-based). On AKS, you choose between Azure CNI with Calico or the Azure Network Policy Manager at cluster creation.

The critical implication: if you have NetworkPolicy objects in your cluster but your CNI does not support enforcement, those policies do nothing. Your pods are still wide open. Audit this before assuming you are protected.

Default vs Policy-Enforced networking model

How NetworkPolicy Actually Reduces Your Bill

The cost reduction mechanism is direct. A default-deny egress policy blocks all outbound traffic from matching pods unless an explicit allow rule permits it. Traffic that never reaches the NAT Gateway generates no data processing charge.

The key insight is that most workloads do not need unrestricted external egress. A backend API pod needs to reach a database and maybe one or two downstream services. It does not need to call arbitrary external APIs. A default-deny egress policy with explicit allows for those specific endpoints eliminates all other outbound traffic from that pod.

Teams that have audited their clusters before applying default-deny policies consistently find 40-60% of egress traffic has no legitimate business purpose. Dependency update calls, misconfigured health checks pinging public endpoints, debug tools calling home. These accumulate silently. A single policy change eliminates all of it.

Scenario Monthly NAT GB Data Processing Cost Cross-AZ Cost
No NetworkPolicy, 50 workloads 820 GB $36.90 $18.40
Default-deny egress, explicit allows 310 GB $13.95 $6.20
Default-deny + topology-aware routing 310 GB $13.95 $1.40
Savings 510 GB $22.95/month $17.00/month

One trap to know before you start: NetworkPolicy rules within a namespace are additive with OR logic. If pod A has a policy allowing egress to 10.0.0.0/8, and a second policy allows egress to 0.0.0.0/0, pod A can reach anything. One permissive policy silently undoes all restrictions for every pod it selects. This is the most common way teams think they have enforced egress control but have not.

The correct pattern: one default-deny policy per namespace with a podSelector: {} (matching all pods), then separate allow policies for each workload with specific selectors. Never add a wildcard allow, as that defeats the default-deny entirely.

Building a Default-Deny Egress Policy Without Breaking Production

Do not deploy default-deny on day one. Clusters with undocumented external dependencies will break immediately, and the blast radius is hard to scope in advance. The right sequence is: audit, then enforce.

The audit phase uses existing observability. If you run Cilium, cilium monitor shows real-time traffic flows by pod. With Calico, the Tigera Calico Enterprise flow logs give the same view. Without a policy-aware CNI, you can use VPC Flow Logs filtered to NAT Gateway ENIs, then map source IPs back to pod CIDR blocks.

Spend one to two weeks collecting data. Map every namespace to its external endpoints. Identify which pods genuinely need internet access and which ones are calling external URLs by accident or by legacy configuration.

Audit then enforce rollout sequence

The enforcement phase starts with non-production namespaces. Apply a default-deny egress policy plus explicit allows for the endpoints your audit identified. Run the workloads for 48 hours, watch for connection failures in application logs, and adjust the allow rules.

When non-prod is stable, roll out namespace by namespace in production. Never apply default-deny cluster-wide in a single change. The failure mode if you get it wrong is broken external calls, which can cascade through service dependencies faster than you can roll back.

This approach works well for stateless workloads. It breaks when pods use dynamic external endpoints that are not known at policy-write time — for example, a pod that calls arbitrary customer-provided webhook URLs. In that case, default-deny egress is not viable for that specific workload. Accept the exception, document it, and apply default-deny to every other namespace.

Choosing Your CNI: Calico, Cilium, or AWS Network Policy Controller

The CNI choice determines what NetworkPolicy features you get and how much operational overhead you accept.

Calico is the most widely deployed option. It runs as a daemonset alongside the AWS VPC CNI on EKS, leaving the existing CNI's IPAM and routing intact while adding policy enforcement. Setup is straightforward: install the Tigera Calico operator, and your existing NetworkPolicy objects start being enforced immediately. Calico also supports GlobalNetworkPolicy (a Calico-specific CRD) which lets you apply cluster-wide default-deny rules without writing a policy per namespace.

Cilium replaces the CNI entirely. Its eBPF dataplane bypasses iptables, which matters at scale: iptables rule processing time grows linearly with rule count, while eBPF is O(1). Cilium also provides Hubble, a network observability layer that shows per-connection flow data without additional tooling.

AWS Network Policy Controller (available since EKS 1.25) is the zero-friction option for EKS users. It works natively with the AWS VPC CNI, requires no CNI replacement, and is installable as a managed EKS addon. The tradeoff: it enforces only standard Kubernetes NetworkPolicy spec with no extensions.

CNI Option Enforcement Layer EKS Setup Observability Cluster-Wide Policy
AWS NPC addon iptables via VPC CNI Managed addon None built-in No
Calico (standalone) iptables + nftables Operator install Flow logs (Enterprise) GlobalNetworkPolicy CRD
Cilium eBPF (replaces CNI) Full CNI migration Hubble (built-in) CiliumClusterwideNetworkPolicy

For teams already working on Kubernetes multi-tenancy with namespace isolation, default-deny NetworkPolicy is a natural extension: the same namespace boundary that isolates resource quotas also becomes the unit of egress control.

Connecting NetworkPolicy to Your FinOps Process

NetworkPolicy enforcement changes your NAT Gateway cost trajectory. But it only produces lasting savings if the policy is maintained as workloads change. That requires connecting the security and cost disciplines together.

The practical mechanism is a monthly egress review. Run VPC Flow Logs or Cilium Hubble queries to find pods generating the most NAT Gateway traffic. Compare against their NetworkPolicy allow rules. If a pod is hitting allowed endpoints at high volume, those are legitimate calls to optimize at the application layer. If a pod is hitting endpoints not in your allowlist, your policy has a gap.

Teams that treat this as a one-time setup see savings erode over 6-12 months as new workloads deploy with incomplete policy coverage. Teams that make egress policy review part of their regular cloud cost governance practice hold the savings.

A sudden spike in NAT Gateway data processing is almost always a new workload without egress policy. Alerting on that metric gives you a feedback loop that catches gaps before they compound.

NetworkPolicy does not automatically understand your workload's external dependencies or write allow rules for you. The audit work is manual. The policy maintenance is ongoing. But the cost reduction is real, the security benefit is real, and the two come from the same configuration change. Most cost controls in cloud infrastructure require dedicated engineering effort for financial benefit alone. This one delivers both simultaneously.