← Về danh sách bài học Bài 11/25

🌐 Bài 11: Kubernetes Networking

⏱️ Thời gian: 20 phút | 📚 Độ khó: Trung bình

🎯 Sau bài học này, bạn sẽ:

1. Nguyên Tắc Networking K8s

📌 K8s Network Model:
• Mọi Pod có IP riêng (không cần NAT)
• Pods trên mọi nodes giao tiếp trực tiếp
• Containers trong Pod chia sẻ network namespace

2. Các Loại Communication

Loại Mô tả
Container-to-Container localhost trong cùng Pod
Pod-to-Pod Direct IP hoặc qua Service
Pod-to-Service ClusterIP, DNS
External-to-Service NodePort, LoadBalancer, Ingress

3. CNI Plugins

Container Network Interface - plugin cung cấp networking cho pods.

# Các CNI phổ biến:
# - Calico (phổ biến, hỗ trợ Network Policy)
# - Flannel (đơn giản)
# - Weave Net
# - Cilium (eBPF, advanced)

# Kiểm tra CNI
kubectl get pods -n kube-system | grep -E 'calico|flannel|weave'

4. CoreDNS - Service Discovery

# DNS format
<service-name>.<namespace>.svc.cluster.local

# Ví dụ
mysql.default.svc.cluster.local
nginx-service.production.svc.cluster.local

# Trong cùng namespace, chỉ cần:
mysql
# Test DNS
kubectl run test --image=busybox -it --rm -- nslookup kubernetes
kubectl run test --image=busybox -it --rm -- nslookup my-service

📝 Tóm Tắt