RousselTMLEARNING

Containers

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

Understand the Kubernetes architecture: API server, etcd, scheduler, controller manager, kubelet, kube-proxy, container runtime, basic objects and the reconciliation loop.

1. The control plane #

The brain of the cluster.

The components #

Architecture of a Kubernetes cluster
All components talk to the API server; only it writes to etcd.
ComponentRole
kube-apiserverREST API, authentication, authorization, admission; the only access point to etcd
etcdDistributed key/value store holding the entire cluster state (back it up!)
kube-schedulerChooses a pod's node based on resources, affinities and constraints
kube-controller-managerControl loops: replicas, nodes, endpoints, jobs...
cloud-controller-managerIntegration with the cloud provider (load balancers, volumes)

2. Worker nodes #

Where pods run.

kubelet, runtime and kube-proxy #

  • kubelet: the node agent; starts the containers described by pods and reports their status.
  • Container runtime (containerd, CRI-O): actually runs the containers through the CRI interface.
  • kube-proxy: programs the network rules (iptables/IPVS) for Services.
kubectl get nodes -o wide
kubectl describe node <noeud> | sed -n '/Capacity/,/Allocated resources/p'
kubectl get --raw='/readyz?verbose' | head -20            # santé de l'API server
kubectl -n kube-system get pods -o wide                   # composants système
kubectl cluster-info
crictl ps                                                 # sur un nœud : conteneurs (runtime CRI)

3. The reconciliation loop #

The declarative principle.

Desired state vs observed state #

Kubernetes is declarative: you describe the desired state (« 3 replicas of this application ») and controllers act continuously so that the actual state converges toward the desired state. If a pod disappears, another one is recreated without intervention.

Kubernetes reconciliation loop
Each controller runs this loop for its object type.
kubectl create deployment web --image=nginx --replicas=3
kubectl delete pod -l app=web --wait=false        # supprimer les pods
kubectl get pods -l app=web -w                    # de nouveaux pods apparaissent aussitôt
kubectl get events --sort-by=.lastTimestamp | tail

4. The basic objects #

The vocabulary to know.

Overview #

ObjectRoleExample
PodSmallest deployable unit (1 or more containers)kubectl run
ReplicaSet / DeploymentMaintains N pods; handles updateskubectl create deployment
ServiceStable access point to podsClusterIP, NodePort, LoadBalancer
Ingress / GatewayHTTP routing from outsidenginx, HAProxy, Traefik
ConfigMap / SecretConfiguration and sensitive datavariables, files
PersistentVolumeClaimRequest for persistent storageStorageClass
NamespaceLogical isolationdev, prod
Job / CronJobOne-off or scheduled tasksbackups
kubectl api-resources | head -30            # toutes les ressources disponibles
kubectl explain deployment.spec.strategy       # documentation intégrée d'un champ
kubectl explain pod.spec.containers --recursive | head -40

Related articles

Container network security and Kubernetes networking

Secure the container network: how Docker and Kubernetes networking works, CNI, default-deny NetworkPolicies, …

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

Understand container registries: Docker Hub, GitHub Container Registry, cloud registries (ECR, ACR, Artifact …

kubectl cheat sheet: the essential commands

All the kubectl commands you need day to day: contexts, resources, logs, exec, port-forward, rollouts, debug,…

Keep learning

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!