Kubernetes Architecture and Core Components
Kubernetes Architecture
Kubernetes follows a master-worker architecture, where the master node(s) manage the overall cluster, and worker nodes run the containerized applications. The key components of the Kubernetes architecture are:
graph LR
Master -- Communicate with --> Worker
Master -- Control Plane --> Worker
subgraph Master Node
API-Server
Scheduler
Controller-Manager
etcd
end
subgraph Worker Node
kubelet
kube-proxy
Containers
end
Kubernetes Core Components
API Server
The API server is the central control point of the Kubernetes cluster. It exposes the Kubernetes API, which is used by all other components to interact with the cluster.
Scheduler
The scheduler is responsible for placing new containers onto available worker nodes based on resource requirements, constraints, and policies.
Controller Manager
The controller manager is a collection of controllers that regulate the state of the cluster, such as the replication controller, which ensures that the desired number of pod replicas are running.
etcd
etcd is a distributed key-value store used by Kubernetes to store all cluster data, including configuration information, state of the cluster, and metadata about running containers.
kubelet
The kubelet is the primary "node agent" that runs on each worker node. It is responsible for communicating with the API server, executing pod operations, and reporting the status of the node.
kube-proxy
The kube-proxy is a network proxy that runs on each worker node and is responsible for implementing the Kubernetes networking model, including load balancing and service discovery.
Kubernetes Declarative Configuration
Kubernetes uses declarative configuration, where you define the desired state of your application, and Kubernetes will work to maintain that state. This is done through Kubernetes objects, such as Pods, Deployments, Services, and more, which are defined in YAML or JSON files.
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 3
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app
image: my-app:v1
ports:
- containerPort: 80