Home » Container Networking: Docker, Kubernetes CNI, Service Mesh, Cilium และ eBPF
Container Networking: Docker, Kubernetes CNI, Service Mesh, Cilium และ eBPF
Container Networking: Docker, Kubernetes CNI, Service Mesh, Cilium และ eBPF
Container Networking เป็นพื้นฐานสำคัญของ modern infrastructure Docker networking ใช้ bridge, host, overlay modes สำหรับ container communication, Kubernetes CNI (Container Network Interface) เป็น plugin standard สำหรับ pod networking, Service Mesh (Istio, Linkerd) ให้ observability + security + traffic management ระหว่าง microservices และ Cilium ใช้ eBPF สำหรับ high-performance networking + security ที่ kernel level
Containers มี lifecycle สั้น (ephemeral): สร้าง/ลบตลอดเวลา IP เปลี่ยนทุกครั้ง ทำให้ traditional networking (static IP, VLAN, firewall rules) ใช้ไม่ได้ Container networking ต้อง dynamic, scalable และ policy-driven เพื่อรองรับ microservices architecture ที่มี services หลายร้อยถึงหลายพัน
Docker Networking
| Driver |
Scope |
Use Case |
| bridge (default) |
Single host |
Containers บน host เดียวกัน communicate ผ่าน virtual bridge |
| host |
Single host |
Container ใช้ host’s network stack โดยตรง (no isolation, best performance) |
| none |
Single host |
No networking (isolated container) |
| overlay |
Multi-host |
Containers ข้าม hosts communicate (Docker Swarm, requires key-value store) |
| macvlan |
Single host |
Container ได้ MAC address จริง → เหมือน device บน physical network |
| ipvlan |
Single host |
Share host’s MAC แต่มี IP ของตัวเอง (efficient, less MAC addresses) |
Kubernetes Networking Model
| Principle |
รายละเอียด |
| Pod-to-Pod |
ทุก Pod สามารถ communicate กับทุก Pod โดยไม่ต้อง NAT |
| Node-to-Pod |
ทุก Node สามารถ communicate กับทุก Pod โดยไม่ต้อง NAT |
| Pod IP = Real IP |
IP ที่ Pod เห็นตัวเอง = IP ที่คนอื่นเห็น (no NAT) |
| Flat Network |
ทุก Pod อยู่ใน flat network เดียวกัน (routable, no overlay required) |
Kubernetes CNI Plugins
| CNI Plugin |
Approach |
จุดเด่น |
| Calico |
BGP routing (L3) |
Network policies, BGP peering, high performance, no overlay option |
| Cilium |
eBPF (kernel-level) |
Best performance, L3-L7 policies, observability (Hubble), no iptables |
| Flannel |
Overlay (VXLAN) |
Simple, easy setup (basic networking, no network policies) |
| Weave Net |
Overlay (mesh) |
Encrypted overlay, easy multi-cloud, built-in DNS |
| AWS VPC CNI |
Native VPC |
Pod gets real VPC IP (best for AWS, no overlay overhead) |
| Azure CNI |
Native VNet |
Pod gets real VNet IP (best for Azure) |
Kubernetes Services
| Type |
Scope |
How |
| ClusterIP |
Internal only |
Virtual IP ภายใน cluster (default, ใช้สำหรับ internal communication) |
| NodePort |
External (basic) |
เปิด port บนทุก node (30000-32767) → forward to pods |
| LoadBalancer |
External (cloud) |
Provision cloud load balancer → forward to pods |
| ExternalName |
DNS alias |
Map service name to external DNS name (CNAME) |
| Ingress |
HTTP/HTTPS routing |
L7 routing: hostname/path → service (NGINX, Traefik, Istio) |
| Gateway API |
Next-gen Ingress |
More expressive routing, multi-tenant, role-based (replacing Ingress) |
Service Mesh
| Feature |
รายละเอียด |
| คืออะไร |
Infrastructure layer ที่จัดการ service-to-service communication (sidecar proxy) |
| Data Plane |
Sidecar proxies (Envoy) ที่ inject ข้าง Pod → intercept ทุก traffic |
| Control Plane |
จัดการ configuration, certificates, policies สำหรับ sidecars |
| mTLS |
Automatic mutual TLS ระหว่าง services (encrypted + authenticated) |
| Traffic Management |
Canary deployments, A/B testing, circuit breaker, retries, timeouts |
| Observability |
Distributed tracing, metrics, access logs (without code changes) |
| Authorization |
L7 policies: allow service A → service B on POST /api/orders only |
Service Mesh Solutions
| Solution |
Proxy |
จุดเด่น |
| Istio |
Envoy (sidecar) |
Most features, large community, complex |
| Linkerd |
linkerd2-proxy (Rust) |
Lightweight, simple, fast (lower resource overhead) |
| Cilium Service Mesh |
eBPF (sidecar-free) |
No sidecar needed (kernel-level), best performance |
| Consul Connect |
Envoy or built-in |
Multi-platform (K8s + VMs + bare metal), HashiCorp ecosystem |
Cilium + eBPF
| Feature |
รายละเอียด |
| eBPF |
Run programs ใน Linux kernel (no kernel modification, sandboxed) |
| No iptables |
Replace iptables/kube-proxy ด้วย eBPF → faster packet processing |
| L3-L7 Policies |
Network policies ที่ level HTTP, gRPC, Kafka (ไม่ใช่แค่ IP/port) |
| Hubble |
Observability: flow visibility, service map, DNS monitoring |
| Tetragon |
Runtime security: process execution, file access, network monitoring |
| Service Mesh |
Sidecar-free service mesh (eBPF in kernel = no Envoy sidecar needed) |
| Performance |
10-30% faster than iptables-based solutions at scale |
Network Policies
| Type |
Scope |
Example |
| Kubernetes NetworkPolicy |
L3/L4 (IP, port) |
Allow pod-A → pod-B on TCP 8080 (deny all else) |
| Cilium NetworkPolicy |
L3-L7 (HTTP, DNS) |
Allow pod-A → pod-B on GET /api/v1/* only |
| Calico NetworkPolicy |
L3/L4 + host policies |
Global network policies + host endpoint protection |
| Istio AuthorizationPolicy |
L7 (mTLS identity) |
Allow service-A → service-B on POST /orders (identity-based) |
ทิ้งท้าย: Container Networking = Dynamic, Policy-Driven, Observable
Container Networking Docker: bridge (default), host (performance), overlay (multi-host) Kubernetes: flat network, no NAT, CNI plugins (Calico, Cilium, Flannel, AWS VPC CNI) Services: ClusterIP (internal), LoadBalancer (external), Ingress/Gateway API (L7 routing) Service Mesh: mTLS + traffic management + observability (Istio, Linkerd, Cilium sidecar-free) Cilium: eBPF-based networking (no iptables, L3-L7 policies, Hubble observability) Network Policies: L3/L4 (K8s native) → L7 (Cilium/Istio) — zero trust for microservices
อ่านเพิ่มเติมเกี่ยวกับ EVPN-VXLAN Data Center Fabric และ Network Observability eBPF ที่ siamlancard.com หรือจาก icafeforex.com และ siam2r.com