Kubernetes Workloads
In Kubernetes, a workload is an application running on your cluster. Kubernetes provides several workload resources that help you manage and run your applications effectively.
Think of workloads as different ways to package and run your applications, each designed for specific use cases.
Types of Workloads
Pod
The smallest and simplest Kubernetes object. A Pod represents a single instance of a running process in your cluster.
A Pod can contain one or more containers
Key Points:
- Basic building block of Kubernetes
- Can run one or more containers
- Containers in a Pod share storage and network
- Usually created and managed by higher-level resources
ReplicaSet
Ensures that a specified number of identical Pods are running at any given time.
ReplicaSet maintains multiple identical Pods
Key Points:
- Maintains a stable set of replica Pods
- Automatically replaces failed Pods
- Scales the number of Pods up or down
- Often managed by Deployments
Deployment
Provides declarative updates for Pods and ReplicaSets. You describe a desired state, and the Deployment controller changes the actual state to match.
Deployments enable rolling updates
Key Points:
- Most common way to deploy stateless applications
- Supports rolling updates and rollbacks
- Manages ReplicaSets which manage Pods
- Ideal for web servers, APIs, and microservices
StatefulSet
Manages the deployment and scaling of a set of Pods with persistent identities and stable storage.
StatefulSets maintain stable network identities and storage
Key Points:
- Pods have stable, unique identifiers
- Persistent storage that follows the Pod
- Ordered, graceful deployment and scaling
- Ideal for databases like MySQL, MongoDB, etc.
DaemonSet
Ensures that all (or some) Nodes run a copy of a Pod. As nodes are added to the cluster, Pods are added to them.
DaemonSets run a Pod on every node
Key Points:
- Runs one Pod per node (or subset of nodes)
- Automatically adds Pods to new nodes
- Ideal for node-level services
- Common uses: logging agents, monitoring agents, storage drivers
Job & CronJob
Manage tasks that run to completion rather than continuously running services.
Key Points:
- Job: Creates one or more Pods to run a task to completion
- CronJob: Runs Jobs on a time-based schedule
- Ideal for batch processing, backups, reports
- Pods are deleted after completion
Workloads Quick Reference
| Workload Type | Purpose | When to Use |
|---|---|---|
| Pod | Basic unit running one or more containers | Testing, single-run tasks (usually managed by higher-level resources) |
| ReplicaSet | Maintain a stable set of replica Pods | Ensuring a specific number of identical Pods are running |
| Deployment | Manage stateless applications with updates | Web servers, APIs, microservices (most common) |
| StatefulSet | Manage stateful applications with stable identities | Databases, applications requiring stable storage |
| DaemonSet | Run a Pod on every node | Log collectors, monitoring agents, storage drivers |
| Job/CronJob | Run tasks to completion or on a schedule | Batch processing, backups, scheduled reports |