Skip to main content

Command Palette

Search for a command to run...

1)πŸš€Kubernetes ArchitectureπŸš€

Updated
β€’9 min readβ€’View as Markdown

πŸš€ Master Node Components in Kubernetes (K8s) – Explained in Detail

In Kubernetes (K8s), the Master Node is the brain 🧠 of the cluster. It controls and manages worker nodes and ensures applications run as expected. The master node consists of several key components that work together for scheduling, state management, and cluster control.


πŸ”Ή 1. Overview of Master Node Components

The Master Node contains these main components:

  1. API Server (kube-apiserver) – The front-end and gateway of Kubernetes.

  2. Controller Manager (kube-controller-manager) – Manages controllers that handle cluster operations.

  3. Scheduler (kube-scheduler) – Decides which node runs which Pod.

  4. Etcd – The key-value store that holds cluster data.

  5. Cloud Controller Manager (cloud-controller-manager) – Integrates Kubernetes with cloud providers (AWS, GCP, Azure, etc.).


πŸ”Ή 2. Components of the Kubernetes Master Node

1️⃣ Kube API Server (kube-apiserver) – The Gateway of Kubernetes πŸšͺ

πŸ’‘ Think of it as the "front desk" of Kubernetes, handling all requests.

βœ… Key Responsibilities:

  • Acts as the entry point for all administrative tasks.

  • Exposes a RESTful API for communication (kubectl, UI, automation tools).

  • Validates incoming requests and forwards them to the right components.

  • Handles authentication and authorization (RBAC, tokens, certificates).

  • Only component that directly communicates with etcd (Kubernetes database).

πŸ—οΈ How it Works:

  1. A user runs a command like kubectl apply -f deployment.yaml.

  2. kube-apiserver validates the request and updates the etcd database.

  3. Other components (scheduler, controllers) pick up the changes and act accordingly.

πŸ”§ Example API Call (Using cURL)

curl -k -X GET https://<master-node-ip>:6443/api/v1/nodes \
    --header "Authorization: Bearer <your-token>"

This fetches all nodes in the cluster.

πŸš€ Why is the API Server Critical?

βœ… Every interaction with the Kubernetes cluster goes through it.
βœ… It ensures security, validation, and authentication of requests.
βœ… High availability is critical (usually runs in multiple replicas).


2️⃣ Etcd – The Brain of Kubernetes 🧠

πŸ’‘ Think of etcd as Kubernetes' "memory" where all cluster data is stored.

βœ… Key Responsibilities:

  • Stores all cluster data in a distributed key-value store.

  • Holds configuration details, state, metadata, and secrets.

  • Ensures data consistency across the cluster.

  • Used by the API Server to get the current state of the cluster.

πŸ—οΈ How it Works:

  • When you create a Deployment, kube-apiserver stores it in etcd.

  • Other components check etcd to see what they need to do.

πŸ” Example: Querying etcd Manually

ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 \
    --cert=/etc/kubernetes/pki/etcd-server.crt \
    --key=/etc/kubernetes/pki/etcd-server.key \
    --cacert=/etc/kubernetes/pki/etcd-ca.crt get /registry/pods --prefix

This command retrieves all stored Pods in etcd.

πŸš€ Why is etcd Critical?

βœ… Without etcd, Kubernetes cannot function.
βœ… Highly distributed & fault-tolerant (runs on multiple master nodes).
βœ… Needs regular backups to prevent cluster failure.


3️⃣ Kube Scheduler (kube-scheduler) – The Brains Behind Pod Placement 🎯

πŸ’‘ The "traffic controller" of Kubernetes that decides where to run new Pods.

βœ… Key Responsibilities:

  • Watches for new unscheduled Pods in the cluster.

  • Decides which node should run each Pod.

  • Uses a scoring system based on:

    • Node capacity (CPU, memory, disk, network).

    • Node labels and taints (to match workloads to nodes).

    • Affinity/anti-affinity rules.

    • Custom constraints defined by admins.

πŸ—οΈ How it Works:

  1. A Pod is created, but it doesn't have a node assigned yet.

  2. kube-scheduler evaluates all available nodes.

  3. It selects the best node and assigns the Pod.

  4. The assignment is sent to the API Server, which updates etcd.

πŸ” Example: Checking Scheduler Decisions

kubectl get events --sort-by=.metadata.creationTimestamp

This shows scheduling events, like when a Pod was placed on a node.

πŸš€ Why is the Scheduler Important?

βœ… Ensures efficient resource usage across the cluster.
βœ… Prevents overloading nodes (avoids running too many Pods on one node).
βœ… Can be customized to handle different scheduling rules.


4️⃣ Kube Controller Manager (kube-controller-manager) – The Automated Operator πŸ€–

πŸ’‘ Think of this as an "auto-pilot" that keeps the cluster running smoothly.

βœ… Key Responsibilities:

  • Runs multiple controllers to maintain the cluster state.

  • Ensures that desired state = actual state.

  • Automatically fixes issues (e.g., restarts failed Pods).

πŸ—οΈ Key Controllers Inside kube-controller-manager:

  1. Node Controller – Detects when a node goes offline and reschedules Pods.

  2. Replication Controller – Ensures the correct number of Pods are running.

  3. Endpoints Controller – Manages networking and service discovery.

  4. Service Account Controller – Manages authentication for Pods.

πŸ” Example: Checking Controller Actions

kubectl get pods --all-namespaces

Shows which Pods are being managed by controllers.

πŸš€ Why is it Important?

βœ… Ensures self-healing – if something breaks, it fixes it automatically.
βœ… Maintains the desired cluster state.


5️⃣ Cloud Controller Manager (cloud-controller-manager) – The Cloud Connector ☁️

πŸ’‘ Used in cloud environments to integrate Kubernetes with AWS, GCP, Azure, etc.

βœ… Key Responsibilities:

  • Manages cloud-specific resources like:

    • Load balancers (AWS ELB, GCP LB).

    • Storage (AWS EBS, Azure Disks).

    • Node management (adding/removing cloud VMs).

  • Separates cloud provider logic from core Kubernetes code.

πŸš€ Why is it Important?

βœ… Allows hybrid cloud & multi-cloud support.
βœ… Decouples cloud-specific operations from Kubernetes core.


πŸ”Ή Conclusion: How Master Node Works in Kubernetes

1️⃣ User requests a new Pod (kubectl apply -f app.yaml).
2️⃣ kube-apiserver validates the request & stores it in etcd.
3️⃣ kube-scheduler finds the best node for the Pod.
4️⃣ kube-controller-manager ensures the Pod is running correctly.
5️⃣ If running on a cloud, cloud-controller-manager integrates cloud services.


πŸ”₯ Final Thoughts

  • The Master Node is the "brain" of Kubernetes, managing everything.

  • Without etcd, Kubernetes would lose all state.

  • The API Server is the most important component, handling all requests.

  • The Scheduler and Controller Manager ensure smooth automation.

  • Cloud Controller Manager helps with multi-cloud deployments.

πŸš€ Worker Node Components in Kubernetes (K8s) – Explained in Detail

In Kubernetes (K8s), the Worker Node is responsible for running application workloads in the form of Pods. While the Master Node controls and manages the cluster, the Worker Node executes workloads as instructed by the Master.


πŸ”Ή 1. Overview of Worker Node Components

Each Worker Node contains the following major components:

1️⃣ Kubelet – The agent that runs on each worker node and communicates with the Master.
2️⃣ Container Runtime – Runs containers inside Pods (e.g., Docker, containerd, CRI-O).
3️⃣ Kube Proxy – Handles networking and ensures communication between services.
4️⃣ Pods – The smallest unit in Kubernetes, containing one or more containers.


πŸ”Ή 2. Components of the Kubernetes Worker Node

1️⃣ Kubelet – The Node’s Brain 🧠

πŸ’‘ The "worker node manager" that ensures Pods run properly.

βœ… Key Responsibilities:

  • Registers the worker node with the Kubernetes Master.

  • Communicates with the API Server to get assigned Pods.

  • Ensures Pods are running on the node as per desired state.

  • Monitors Pod health and reports back to the Master.

  • Manages Pod lifecycle (starting, stopping, and restarting).

πŸ—οΈ How it Works:

1️⃣ The Master Node assigns a Pod to a worker node.
2️⃣ The kubelet on that node fetches Pod details from the API Server.
3️⃣ It ensures the correct containers are running using the Container Runtime.
4️⃣ If a container crashes, kubelet restarts it automatically.

πŸ”§ Example: Checking Kubelet Logs

journalctl -u kubelet -f

This shows live logs of the kubelet process.

πŸš€ Why is Kubelet Important?

βœ… Ensures Pods stay in the desired state.
βœ… Restarts failed Pods automatically.
βœ… Reports node health to the Master.


2️⃣ Container Runtime – The Engine that Runs Containers βš™οΈ

πŸ’‘ The "engine" that runs the actual containers inside Kubernetes Pods.

βœ… Key Responsibilities:

  • Pulls container images from Docker Hub, AWS ECR, GCP Artifact Registry, etc.

  • Runs containers inside Pods.

  • Handles container networking & storage.

  • Ensures containers are started, stopped, and restarted when needed.

πŸ—οΈ Common Container Runtimes in Kubernetes:

  • Docker (older, widely used but being deprecated in K8s).

  • containerd (lightweight and optimized for Kubernetes).

  • CRI-O (developed specifically for Kubernetes).

  • Podman (alternative to Docker).

πŸ”§ Example: Checking Running Containers

crictl ps

This lists all running containers on a node.

πŸš€ Why is the Container Runtime Important?

βœ… Runs the actual application workloads inside containers.
βœ… Fetches and starts containers as per kubelet instructions.
βœ… Supports different container runtimes for flexibility.


3️⃣ Kube Proxy – The Network Bridge 🌐

πŸ’‘ Handles networking and ensures communication between Pods and Services.

βœ… Key Responsibilities:

  • Maintains networking rules to route traffic between Pods.

  • Handles Load Balancing inside the cluster.

  • Uses iptables, IPVS, or eBPF to route traffic efficiently.

  • Enables communication between services, even across nodes.

πŸ—οΈ How it Works:

1️⃣ A Pod needs to communicate with another Pod on a different node.
2️⃣ kube-proxy sets up networking rules to enable communication.
3️⃣ The request is routed correctly to the destination Pod.

πŸ”§ Example: Checking Kube Proxy Logs

journalctl -u kube-proxy -f

This shows live logs of the kube-proxy process.

πŸš€ Why is Kube Proxy Important?

βœ… Enables seamless networking between Pods.
βœ… Handles Load Balancing for services.
βœ… Supports multiple networking modes (iptables, IPVS, eBPF).


4️⃣ Pods – The Smallest Unit in Kubernetes 🏠

πŸ’‘ A "Pod" is a wrapper around one or more containers.

βœ… Key Responsibilities:

  • Runs application containers inside it.

  • Shares network and storage among its containers.

  • Managed by Kubernetes through Deployments, StatefulSets, DaemonSets, etc.

πŸ—οΈ Example Pod YAML Definition:

apiVersion: v1
kind: Pod
metadata:
  name: my-pod
spec:
  containers:
    - name: my-container
      image: nginx
      ports:
        - containerPort: 80
kubectl apply -f my-pod.yaml

This deploys a simple Nginx Pod on a worker node.

πŸš€ Why are Pods Important?

βœ… Encapsulate applications inside containers.
βœ… Can have multiple containers sharing storage & networking.
βœ… Can be scaled easily using Deployments & Auto-Scaling.


πŸ”Ή 3. How the Worker Node Works in Kubernetes

1️⃣ The Master Node assigns Pods to Worker Nodes.
2️⃣ The kubelet fetches Pod details from the API Server.
3️⃣ The Container Runtime pulls images and runs containers.
4️⃣ Kube Proxy sets up networking rules for communication.
5️⃣ The Pod runs the application and serves requests.


πŸ”Ή 4. Kubernetes Worker Node vs. Master Node

FeatureMaster Node 🧠Worker Node πŸ—οΈ
PurposeControls and manages clusterRuns applications
ComponentsAPI Server, etcd, Scheduler, Controller ManagerKubelet, Container Runtime, Kube Proxy, Pods
ManagesScheduling, cluster state, networkingRunning Pods and containers
CommunicationTalks to Worker NodesReports to Master Node
Runs Applications?❌ Noβœ… Yes

πŸ”₯ Conclusion

  • Worker Nodes are where applications actually run in Kubernetes.

  • The kubelet ensures Pods are running as per the desired state.

  • The Container Runtime (Docker/containerd/CRI-O) runs containers.

  • The kube-proxy handles networking and communication between Pods.

  • Pods are the smallest deployable unit in Kubernetes.

More from this blog

khushbu's blog

38 posts