finds.dev← search

// the find

ahmetb/kubernetes-network-policy-recipes

★ 6,141 · Apache-2.0 · updated Feb 2025

Example recipes for Kubernetes Network Policies that you can just copy paste

A collection of copy-paste-ready Kubernetes NetworkPolicy YAML examples covering the most common traffic control patterns: deny-all defaults, namespace isolation, port restrictions, and egress controls. Written by Ahmet Alp Balkan (Google), who also gave the canonical KubeCon talk on this topic. Aimed at platform engineers and developers who know they need network policies but aren't sure how to write them.

The recipes are organized by use case rather than API surface, which matches how people actually think about the problem. Each file pairs the YAML with a clear explanation of what it does and why, including the gotchas (empty selectors match everything, policies are additive not overriding). The crash course section upfront covers the non-obvious mental model shifts — no deny rules, default-allow-until-targeted — that trip up most first-timers. Authorship from someone who wrote the KubeCon reference talk gives it credibility.

Several egress recipes are marked 🔜 and never arrived — the repo hasn't had a meaningful commit in years and those stubs have been sitting there since at least 2019. There's nothing here for newer NetworkPolicy features like FQDN-based egress filtering (Cilium) or the alpha AdminNetworkPolicy API that's been in progress since 1.24. The GKE-first cluster setup guide dates it badly; anyone on EKS or kind has to figure out CNI plugin installation on their own. No automated testing — you have to trust the YAML is correct.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →