DELAPARRA
Index
Color
NL
Category: Kubernetes

NetworkPolicy

Explained by Updated

What is NetworkPolicy?

NetworkPolicy: A firewall for Pods. Declares which Pods may talk to which, by label and port. Without one, all Pods can reach all others. A NetworkPolicy is a firewall for pods in Kubernetes. It defines which pods may connect to which, using labels and ports. For example: only pods labelled app=api may reach the database on port 3306.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about NetworkPolicy

How is NetworkPolicy used in practice?

By default, every pod in a cluster can reach every other pod. That is convenient, but it means one compromised container can talk to everything, including databases it has no business with.

What should you keep in mind with NetworkPolicy?

A good starting point is a default policy that blocks incoming traffic in a namespace, followed by specific policies that allow only the connections your application needs. Network policies require a network plugin that enforces them; most managed clusters support this, but check before relying on it. Test policies carefully, because a missing rule silently breaks connections.

What does an example of NetworkPolicy look like?

apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: db-allow-api spec: podSelector: matchLabels: { app: db } ingress: - from: - podSelector: matchLabels: { app: api }

At a glance

CategoryKubernetes
Explained by
Updated

More Kubernetes terms

All terms starting with N

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.