RousselTMLEARNING

Article · Kubernetes: From Discovery to Expertise

Container network security

1. How containers communicate #

Basic networking.

Model #

  • Docker: per-host bridge networks (isolation by named network), overlay networks between Swarm hosts.
  • Kubernetes: each pod has an IP, all pods can reach each other by default; the CNI (Calico, Cilium, Flannel) implements this network.
  • Services provide a stable address; Ingress or the Gateway API expose to the outside.
Common mistake: By default, Kubernetes isolates nothing: a compromised pod can reach every database in the cluster. The first measure is a default-deny policy.

2. The measures #

Layer by layer.

NetworkPolicies #

Layers of container network security
# Refus par défaut dans le namespace, puis ouverture explicite
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: { name: default-deny, namespace: shop }
spec: { podSelector: {}, policyTypes: [Ingress, Egress] }
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata: { name: api-to-db, namespace: shop }
spec:
  podSelector: { matchLabels: { app: postgres } }
  ingress:
    - from: [ { podSelector: { matchLabels: { app: api } } } ]
      ports: [ { port: 5432 } ]
Good to know: NetworkPolicies only apply if the CNI implements them (Calico, Cilium yes; Flannel alone no). Remember to allow DNS (port 53 to kube-dns) in egress rules.

Other layers #

MeasureToolProtects against
mTLS between servicesIstio, Linkerd, CiliumEavesdropping and spoofing on the cluster network
Egress controlEgress policies, outbound proxyData exfiltration, downloading tools
IngressIngress with TLS, WAF, rate limitingApplication attacks
Flow observabilityHubble (Cilium), Network Performance MonitoringUnexpected flows going undetected

📄 Container network security and Kubernetes networking →

My progress

  • ⏱ Estimated time : ≈ 4 min

Sign in to track your progress and take notes. Sign in

💬 Questions about this lesson

No questions yet: be the first to ask for help or share your configuration.

Ask a question about this lesson →

Course Glossary

Kubernetes

An open-source container orchestration engine (sometimes called K8s) for automating the deployment, scaling, and management of containerized applicati...

Recommended Articles

Securing Kubernetes: RBAC, NetworkPolicies, container network security and Pod Security

Securing Kubernetes: RBAC (Role, ClusterRole, bindings), ServiceAccounts, NetworkPolicies, Pod Se...

Kubernetes CNI: Flannel, Calico and Cilium compared

Kubernetes CNI: understand network plugins (Container Network Interface) and compare Flannel, Cal...

Observing the Kubernetes network with Cilium Hubble

Make a Kubernetes cluster's network flows visible with Cilium Hubble: architecture, the hubble ob...

HAProxy in Kubernetes: the high-performance Ingress Controller

Discover in depth how HAProxy integrates with Kubernetes: direct-to-pod architecture, hot update ...

Container registry: choosing and securing your image registry (Docker Hub, Harbor, GHCR, ECR)

Understand container registries: Docker Hub, GitHub Container Registry, cloud registries (ECR, AC...

Kubernetes: architecture and components (control plane, nodes, objects)

Understand the Kubernetes architecture: API server, etcd, scheduler, controller manager, kubelet,...

Kubernetes Services: ClusterIP, NodePort, LoadBalancer and ExternalName

Kubernetes Services explained: the role of a Kubernetes service, the ClusterIP, NodePort, LoadBal...

Kubernetes: exposing your applications (Services, Ingress and Gateway API)

Expose applications in Kubernetes: ClusterIP/NodePort/LoadBalancer Services, Ingress, IngressClas...

ConfigMaps and Secrets

A complete guide to ConfigMaps and Secrets in Kubernetes.

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!