“Learning Kubernetes from Scratch”
01
—
Introduction to Pod Controllers
A Pod is the smallest management unit in Kubernetes. In Kubernetes, Pods can be classified into two categories based on how they are created:
1. Standalone Pods: Pods that are created directly by Kubernetes. Once deleted, these Pods do not exist anymore and will not be recreated.
2. Controller-created Pods: Pods that are created by Kubernetes through controllers. These Pods will be automatically recreated if deleted.
What is a Pod Controller:
A Pod Controller is an intermediary layer that manages Pods. After using a Pod Controller, you only need to inform it how many and what type of Pods you want, and it will create the Pods that meet the criteria and ensure that each Pod resource is in the desired state as expected by the user. If a Pod resource fails during operation, it will re-schedule the Pod based on the specified policy.
In Kubernetes, there are many types of Pod Controllers, each suitable for different scenarios. Common ones include:
ReplicationController: A more primitive Pod controller that has been deprecated and replaced by ReplicaSet.
ReplicaSet: Ensures a specified number of Pods are running and supports changes in the number of Pods and image versions.
Deployment: Controls Pods through ReplicaSet and supports rolling upgrades and version rollbacks; suitable for stateless applications. All Pods are equivalent and can be replaced.
Horizontal Pod Autoscaler: Automatically adjusts the number of Pods horizontally based on cluster load, achieving load balancing.
DaemonSet: Runs on specified Nodes in the cluster and only runs one replica, generally used for daemon-like tasks.
Job: Creates Pods that exit immediately after completing their tasks, without needing to restart or recreate, used for one-time tasks.
CronJob: Creates Pods responsible for periodic task control, without needing to run continuously in the background.
StatefulSet: Manages stateful applications, suitable for types like databases.