Skip to content

Kubernetes (K8s)

Chào mừng đến với Kubernetes - nền tảng orchestration cho containers, được sử dụng bởi hàng nghìn công ty từ startups đến enterprises.

Tổng Quan

Kubernetes (K8s) là hệ thống mã nguồn mở để tự động hóa deployment, scaling và quản lý containerized applications. Nó giúp bạn:

  • 🚀 Deploy: Tự động deploy containers lên cluster
  • 📈 Scale: Auto-scaling dựa trên load
  • 🔄 Self-Healing: Tự động restart failed containers
  • 🔀 Load Balancing: Phân phối traffic đều
  • 📦 Rolling Updates: Zero-downtime deployments

Nội Dung Chính

Module 1: Architecture

  • Kubernetes components
  • Control Plane vs Worker Nodes
  • etcd, API Server, Scheduler, Controller Manager

Module 2: Workloads

  • Pods, Deployments, StatefulSets, DaemonSets
  • Services & Networking
  • Pod lifecycle

Module 3: Networking

  • Services (ClusterIP, NodePort, LoadBalancer)
  • Ingress Controllers
  • DNS & Service Discovery

Module 4: Configuration

  • ConfigMaps & Secrets
  • Environment Variables
  • Volume Mounts

Module 5: Storage

  • Persistent Volumes (PV)
  • Persistent Volume Claims (PVC)
  • Storage Classes
  • StatefulSets

Module 6: Security

  • RBAC (Role-Based Access Control)
  • Network Policies
  • Security Contexts
  • Pod Security Standards

Module 7-9: Advanced

  • Health Checks (Liveness, Readiness, Startup Probes)
  • Resource Management (Requests, Limits, QoS)
  • Horizontal Pod Autoscaler (HPA)

Module 10-11: Observability

  • Logging (Fluentd, Loki)
  • Monitoring (Prometheus, Grafana)
  • Tracing (Jaeger)

Module 12-14: GitOps & CI/CD

  • Helm Charts
  • ArgoCD
  • CI/CD Pipelines

Lộ Trình Học

Week 1-2: Fundamentals

  1. Install kubectl & minikube
  2. Understand Pods & Deployments
  3. Services & Networking basics
  4. ConfigMaps & Secrets

Week 3-4: Core Concepts

  1. StatefulSets & DaemonSets
  2. Persistent Volumes
  3. Ingress Controllers
  4. RBAC basics

Week 5-6: Production Readiness

  1. Health checks
  2. Resource management
  3. Auto-scaling
  4. Network policies

Week 7-8: Advanced

  1. Helm charts
  2. GitOps with ArgoCD
  3. Monitoring & logging
  4. CI/CD integration

Lời khuyên từ Professor Tom

Kubernetes có learning curve cao. Đừng cố học tất cả cùng lúc. Master Pods & Deployments trước, rồi mới đến StatefulSets, Ingress, và các concepts nâng cao.

Kubernetes Architecture

┌─────────────────────────────────────────┐
│           Control Plane                  │
│  ┌──────────┐  ┌──────────┐  ┌────────┐│
│  │API Server│  │Scheduler │  │etcd    ││
│  └──────────┘  └──────────┘  └────────┘│
│  ┌──────────────────────────────────┐  │
│  │Controller Manager                │  │
│  └──────────────────────────────────┘  │
└─────────────────────────────────────────┘

    ┌─────────┴─────────┐
    │                   │
┌───▼────┐         ┌────▼───┐
│Worker 1│         │Worker 2│
│┌──────┐│         │┌──────┐│
││kubelet││         ││kubelet││
│└──────┘│         │└──────┘│
│┌──────┐│         │┌──────┐│
││Pods  ││         ││Pods  ││
│└──────┘│         │└──────┘│
└────────┘         └────────┘

Best Practices

Resource Management

  • ✅ Always set resource requests & limits
  • ✅ Use Horizontal Pod Autoscaler
  • ✅ Implement Pod Disruption Budgets
  • ✅ Use Quality of Service (QoS) classes

Security

  • ✅ Enable RBAC
  • ✅ Use Network Policies
  • ✅ Scan images for vulnerabilities
  • ✅ Don't run as root
  • ✅ Use Pod Security Standards

High Availability

  • ✅ Multi-replica deployments
  • ✅ Pod anti-affinity rules
  • ✅ Health checks (liveness, readiness)
  • ✅ Rolling updates strategy

Observability

  • ✅ Centralized logging
  • ✅ Metrics collection (Prometheus)
  • ✅ Distributed tracing
  • ✅ Alerting rules

Tools & Ecosystem

Cluster Management

  • minikube: Local development
  • kind: Kubernetes in Docker
  • k3s: Lightweight Kubernetes
  • EKS/GKE/AKS: Managed Kubernetes

Package Management

  • Helm: Kubernetes package manager
  • Kustomize: Configuration management

GitOps

  • ArgoCD: Declarative GitOps
  • Flux: GitOps toolkit

Monitoring

  • Prometheus: Metrics collection
  • Grafana: Visualization
  • Jaeger: Distributed tracing

Bắt đầu với Module 1: Architecture!

Cập nhật lần cuối: