Pods
Pods are the smallest deployable compute units in Kubernetes. A Pod can run one or more containers that share networking and storage resources.
Key Topics
- • Containers
- • Pod lifecycle
- • Shared networking
- • Shared storage
Learn how Kubernetes runs and manages applications using Pods and workload resources such as Deployments, ReplicaSets, StatefulSets, DaemonSets, Jobs, and CronJobs.
Kubernetes Workloads
Pods
Deployments & ReplicaSets
StatefulSets
DaemonSets
Jobs
CronJobs
Introduction
Kubernetes applications ultimately run inside Pods. A Pod can contain one or more containers and represents the smallest deployable compute unit in a Kubernetes cluster.
Instead of manually managing individual Pods, Kubernetes provides workload resources that create, manage, replace, scale, and update Pods according to the desired configuration.
These workload resources allow Kubernetes to manage different types of applications, including stateless services, stateful applications, node-level services, and scheduled tasks.
Core Concepts
Different Kubernetes workload resources are designed for different application requirements and operational models.
Pods are the smallest deployable compute units in Kubernetes. A Pod can run one or more containers that share networking and storage resources.
Key Topics
Deployments manage application workloads and provide declarative updates, scaling, and controlled rollout of Pods.
Key Topics
ReplicaSets maintain a specified number of identical Pod replicas and are commonly managed automatically by Deployments.
Key Topics
StatefulSets manage applications that require stable identities, persistent storage, or ordered deployment and scaling.
Key Topics
DaemonSets ensure that Pods run on selected nodes, making them useful for node-level services such as monitoring and logging.
Key Topics
Jobs run tasks to completion, while CronJobs create Jobs repeatedly according to a defined schedule.
Key Topics
Pods
A Pod represents one or more containers running together inside a Kubernetes cluster. Containers inside the same Pod can share networking and storage resources.
Although Pods can be created directly, application workloads are generally managed through higher-level Kubernetes resources such as Deployments, StatefulSets, or Jobs.
Simple Pod Example
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80Deployments
A Deployment manages a set of Pods and is commonly used for stateless application workloads.
Deployments support declarative updates, scaling, controlled rollouts, and rollback operations when application changes are deployed.
Deployment Example
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-app
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginxReplicaSets
A ReplicaSet maintains a stable number of matching Pod replicas. If a managed Pod is removed or fails, the ReplicaSet can create a replacement to help maintain the desired replica count.
In most application deployments, ReplicaSets are managed automatically by a Deployment rather than being managed directly.
Replica Relationship
Deployment
│
▼
ReplicaSet
│
┌───┼───┐
▼ ▼ ▼
Pod Pod Pod
Desired Replicas: 3StatefulSets
StatefulSets are designed for workloads that require stable, unique identities and may need persistent storage.
Unlike Pods managed by a typical Deployment, Pods in a StatefulSet are not interchangeable in the same way and can maintain persistent identifiers across rescheduling.
StatefulSet Example
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: database
spec:
serviceName: database
replicas: 3
selector:
matchLabels:
app: databaseDaemonSets
DaemonSets manage Pods that provide node-level functionality. Kubernetes can schedule these Pods across all or selected nodes that match the workload requirements.
Common use cases include monitoring agents, log collection, and other services that need to run close to the nodes they support.
Cluster ┌─────────────┐ │ Node 1 │ │ Daemon Pod │ └─────────────┘ ┌─────────────┐ │ Node 2 │ │ Daemon Pod │ └─────────────┘ ┌─────────────┐ │ Node 3 │ │ Daemon Pod │ └─────────────┘
Jobs and CronJobs
A Job is used for workloads that perform a task and then finish. This makes Jobs useful for batch processing, migrations, reports, and other run-to-completion tasks.
A CronJob creates Jobs according to a defined schedule and can be used for recurring tasks such as backups, reports, and automated maintenance.
CronJob Example
apiVersion: batch/v1
kind: CronJob
metadata:
name: backup-job
spec:
schedule: "0 2 * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: backup
image: backup-image
restartPolicy: OnFailurekubectl
Use kubectl to inspect and manage Pods and Kubernetes workload resources.
kubectl get podsDisplay Pods in the current namespace.
kubectl get deploymentsDisplay Deployments.
kubectl get replicasetsDisplay ReplicaSets.
kubectl get statefulsetsDisplay StatefulSets.
kubectl get daemonsetsDisplay DaemonSets.
kubectl get jobsDisplay Jobs.
kubectl get cronjobsDisplay CronJobs.
kubectl apply -f app.yamlCreate or update resources from a YAML manifest.
Learning Roadmap
Follow this learning path to understand how Kubernetes manages different types of application workloads.
Learn how Pods run containers and why Pods are the foundation of Kubernetes workloads.
Use Deployments to manage stateless applications, replicas, updates, and rollbacks.
Learn how ReplicaSets maintain the desired number of running Pods.
Understand how Kubernetes manages stateful applications with persistent identity and storage.
Learn how to run node-level workloads such as monitoring and logging agents.
Run one-time and scheduled workloads using Kubernetes Jobs and CronJobs.
Best Practices
Use workload resources to manage application Pods instead of manually managing individual Pods for most production workloads.
Use Deployments for many stateless workloads and consider StatefulSets when stable identity or persistent storage is required.
Apply consistent labels so Kubernetes resources can be selected, grouped, and managed effectively.
Store Kubernetes YAML manifests in version control to improve consistency and change management.
Inspect Pods, workload resources, events, and logs to understand application health and troubleshoot issues.
Learn how replica counts and workload controllers help Kubernetes scale applications and maintain the desired state.
Continue Learning
Learn Kubernetes architecture, clusters, nodes, Pods, Deployments, Services, Namespaces, and kubectl.
⚙️Explore Kubernetes concepts, workloads, networking, storage, scaling, and cluster management.
🐳Learn containers, Docker images, Dockerfiles, volumes, and networking before advancing further with Kubernetes.
Next Step
Start with Pods and Deployments, then explore ReplicaSets, StatefulSets, DaemonSets, Jobs, and CronJobs to understand how Kubernetes manages different application workloads.