Workloads & Scheduling
Workloads are the applications and tasks that run on your Kubernetes cluster. They define what containers should run, how many replicas you need, how they should be updated, and how Kubernetes should schedule them onto nodes. The workloads section covers everything from stateless applications to databases, from one-time batch jobs to continuously running services.
What Are Workloads?
In Kubernetes, a workload is any resource that creates and manages pods—the basic execution unit in Kubernetes. Workloads handle the lifecycle of pods: creating them, ensuring the right number are running, replacing failed pods, and updating them when you deploy new versions.
Types of Workloads
Kubernetes provides different workload types for different use cases:
Stateless Workloads
Deployments - The most common workload for stateless applications. They manage pod replicas and handle rolling updates automatically. Perfect for web servers, APIs, and most microservices.
ReplicaSets - The underlying mechanism that Deployments use to ensure a specific number of pod replicas are running. You typically use Deployments, which manage ReplicaSets for you.
Stateful Workloads
StatefulSets - Designed for stateful applications that need stable network identity, stable storage, and ordered deployment. Used for databases, message queues, and distributed systems with state.
Node-Level Workloads
DaemonSets - Ensures that one pod runs on every node (or specific nodes). Perfect for logging agents, monitoring tools, and cluster-wide utilities.
Batch Workloads
Jobs - Run a task to completion. Used for one-time work like data processing, backups, or migrations. Jobs can run in parallel and retry on failure.
CronJobs - Schedule Jobs to run at specific times. Useful for periodic tasks like backups, reports, or cleanup jobs.
Configuration and Data
Workloads often need configuration and sensitive data:
ConfigMaps - Store non-sensitive configuration data. Decouple configuration from container images, making it easier to manage environment-specific settings.
Secrets - Store sensitive data like passwords, tokens, and keys. Similar to ConfigMaps but designed for sensitive information with additional security considerations.
Autoscaling
Kubernetes can automatically adjust the number of pods based on demand:
- Horizontal Pod Autoscaler (HPA) - Scales the number of pod replicas based on CPU, memory, or custom metrics
- Vertical Pod Autoscaler (VPA) - Adjusts CPU and memory requests for pods based on actual usage
Resilience
Applications need to handle failures gracefully:
- Health Probes - Liveness, readiness, and startup probes ensure pods are healthy and ready to serve traffic
- Pod Disruption Budgets - Control how many pods can be disrupted during voluntary operations like node maintenance
Scheduling
The Kubernetes scheduler places pods onto nodes based on:
- Resource Requests and Limits - CPU and memory requirements
- Affinity and Anti-Affinity - Rules for placing pods together or apart
- Taints and Tolerations - Node-level restrictions and exceptions
- Topology Spread Constraints - Distribute pods across zones and nodes
- Priority and Preemption - Important pods can evict less important ones
Workload Lifecycle
Every workload follows a lifecycle:
Choosing the Right Workload
Selecting the appropriate workload type depends on your application’s characteristics:
Use Deployments when:
- ✅ Application is stateless
- ✅ Pods are interchangeable
- ✅ You need rolling updates
- ✅ Simple scaling requirements
Use StatefulSets when:
- ✅ Application requires stable network identity
- ✅ Each pod needs unique, persistent storage
- ✅ Pods must start/stop in order
- ✅ Application is a database or distributed system with state
Use DaemonSets when:
- ✅ You need one pod per node
- ✅ Cluster-wide utility (logging, monitoring)
- ✅ Node-level operations
Use Jobs when:
- ✅ Task runs to completion
- ✅ One-time or batch processing
- ✅ Retry on failure needed
Use CronJobs when:
- ✅ Scheduled, recurring tasks
- ✅ Periodic maintenance
- ✅ Regular reports or backups
Topics
Workload Resources
- Deployments - Stateless application deployments with rolling updates
- ReplicaSets - Pod replica management
- StatefulSets - Stateful applications with stable identity
- DaemonSets - One pod per node workloads
- Jobs - Run-to-completion tasks
- CronJobs - Scheduled jobs
Configuration
- ConfigMaps - Configuration management
- Secrets - Sensitive data management
Autoscaling
- Autoscaling - Automatic scaling of workloads
Resilience
- Resilience Patterns - Health checks and disruption management
Scheduling
- Scheduling - Pod scheduling and placement
See Also
- Pod Basics - Understanding the basic pod resource
- Services - Exposing workloads via network services
- Storage - Persistent storage for stateful workloads
- RBAC - Security and access control for workloads