Instead of running individual pods, you create workload resources that manage set of pods based on a declared desired state.
When you submit workload resource, K8s control plane configures corresponding controller. Controllers run control loops, where controller periodically makes sure that status of resource corresponds to declared desired state.
Most Kubernetes objects have two fields:
Deployment: suitable for stateless apps, like web servers. can have one or more containers.
kubectl edit
, or kubectl scale deployment <name> --replicas=n
kubectl autoscale deployment <name> --min=7 --max=8 --cpu-percent=60
ReplicaSet: maintains desired number of instances of a pod defined by a template
DaemonSet: ensures pods run on each node of the cluster, even if nodes added at later time
Job: ensures that specific task completes even if pod that should run the task fails
CronJob: causes pod to execute at specific times determined by schedule
parameter (like cron
)
Garbage Collector: responsible for deleting objects when their parent no longer exists
blockOwnerDeletion: true
are deleted, then the parent is deleted