kubernetes intro

Kubernetes Visualization

Kubernetes Visualization

Loading data from Wikipedia...

Control Plane

The Control Plane in Kubernetes is the core component responsible for managing the state and operation of the cluster. It oversees everything from scheduling pods to maintaining the desired state of the cluster.

Etcd

Etcd is a persistent, lightweight, distributed, key-value data store (originally developed for Container Linux). It reliably stores the configuration data of the cluster, representing the overall state of the cluster at any given point of time.

API Server

The API server serves the Kubernetes API using JSON over HTTP.

Scheduler

The scheduler selects nodes for unscheduled pods based on resource availability.

Controllers

Controllers drive the cluster state toward the desired state.

Nodes

Nodes are machines where containers (workloads) are deployed.

Namespaces

Namespaces segregate resources into distinct collections.

Pods

A pod is the basic scheduling unit in Kubernetes, consisting of one or more containers.

Example: Deploying a Pod Using kubectl

Let’s say you want to run an Nginx container in your Kubernetes cluster.

Step 1: Write a Pod Definition YAML File

# nginx-pod.yaml
apiVersion: v1
kind: Pod
metadata:
  name: nginx-pod
  labels:
    app: nginx
spec:
  containers:
  - name: nginx
    image: nginx:1.21
    ports:
    - containerPort: 80
    

Step 2: Apply the YAML File

Use the kubectl command to tell the Kubernetes API server to create this Pod:

kubectl apply -f nginx-pod.yaml

What Happens in the Control Plane?

API Server:

The kubectl apply command communicates with the Kubernetes API server. The API server validates the YAML file and records the desired state in the etcd database.

etcd:

Stores the desired state of the cluster (e.g., the pod nginx-pod should exist).

Scheduler:

The Scheduler identifies the best node to place the Pod based on available resources, policies, and constraints.

Controller Manager:

The Replication Controller notices that the desired state (a running Pod) does not match the current state (no Pod exists).

Kubelet:

The Kubelet (running on the chosen worker node) receives instructions from the Control Plane. It pulls the nginx:1.21 Docker image and starts the container.

Kube Proxy:

Configures networking rules to allow communication to and from the Pod.

Summary

Run the following command to check the status of the Pod:

kubectl get pods

NAME READY STATUS RESTARTS AGE

nginx-pod 1/1 Running 0 1m

The Control Plane components like the API Server, Scheduler, Controller Manager, and etcd worked together to deploy the nginx-pod. The Worker Node components (Kubelet and Kube Proxy) ensured the Pod was scheduled and running.

This demonstrates the orchestration power of the Control Plane in maintaining the desired state of a Kubernetes cluster.

Comments