TechyPilots Info
TechyPilots.INFO
Home/Tutorials/Kubernetes/Pods and Workloads
Kubernetes Tutorial

Kubernetes Pods and Workloads

Learn how Kubernetes runs and manages applications using Pods and workload resources such as Deployments, ReplicaSets, StatefulSets, DaemonSets, Jobs, and CronJobs.

Level: Beginner
Topics: 6 Workload Types

Kubernetes Workloads

Application Management

Pods

Deployments & ReplicaSets

StatefulSets

DaemonSets

Jobs

CronJobs

Introduction

What are Kubernetes Pods and Workloads?

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

Kubernetes workload types

Different Kubernetes workload resources are designed for different application requirements and operational models.

01

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
02

Deployments

Deployments manage application workloads and provide declarative updates, scaling, and controlled rollout of Pods.

Key Topics

  • Stateless applications
  • Rolling updates
  • Scaling
  • Rollbacks
03

ReplicaSets

ReplicaSets maintain a specified number of identical Pod replicas and are commonly managed automatically by Deployments.

Key Topics

  • Pod replicas
  • Desired state
  • Availability
  • Pod replacement
04

StatefulSets

StatefulSets manage applications that require stable identities, persistent storage, or ordered deployment and scaling.

Key Topics

  • Persistent identity
  • Stable storage
  • Ordered deployment
  • Stateful applications
05

DaemonSets

DaemonSets ensure that Pods run on selected nodes, making them useful for node-level services such as monitoring and logging.

Key Topics

  • Node-level workloads
  • Monitoring agents
  • Logging agents
  • Cluster services
06

Jobs & CronJobs

Jobs run tasks to completion, while CronJobs create Jobs repeatedly according to a defined schedule.

Key Topics

  • Batch processing
  • One-time tasks
  • Scheduled tasks
  • Automation

Pods

The foundation of Kubernetes workloads

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: 80

Deployments

Manage stateless applications

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: nginx

ReplicaSets

Maintain the desired number of Pods

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: 3

StatefulSets

Manage stateful applications

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: database

DaemonSets

Run workloads on cluster nodes

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

Run tasks and scheduled workloads

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: OnFailure

kubectl

Useful workload commands

Use kubectl to inspect and manage Pods and Kubernetes workload resources.

kubectl get pods

Display Pods in the current namespace.

kubectl get deployments

Display Deployments.

kubectl get replicasets

Display ReplicaSets.

kubectl get statefulsets

Display StatefulSets.

kubectl get daemonsets

Display DaemonSets.

kubectl get jobs

Display Jobs.

kubectl get cronjobs

Display CronJobs.

kubectl apply -f app.yaml

Create or update resources from a YAML manifest.

Learning Roadmap

How to learn Pods and workloads

Follow this learning path to understand how Kubernetes manages different types of application workloads.

Step 1

Understand Pods

Learn how Pods run containers and why Pods are the foundation of Kubernetes workloads.

Step 2

Learn Deployments

Use Deployments to manage stateless applications, replicas, updates, and rollbacks.

Step 3

Understand ReplicaSets

Learn how ReplicaSets maintain the desired number of running Pods.

Step 4

Explore StatefulSets

Understand how Kubernetes manages stateful applications with persistent identity and storage.

Step 5

Use DaemonSets

Learn how to run node-level workloads such as monitoring and logging agents.

Step 6

Practice Jobs and CronJobs

Run one-time and scheduled workloads using Kubernetes Jobs and CronJobs.

Best Practices

Workload management best practices

Use Workload Controllers

Use workload resources to manage application Pods instead of manually managing individual Pods for most production workloads.

Choose the Right Workload

Use Deployments for many stateless workloads and consider StatefulSets when stable identity or persistent storage is required.

Use Meaningful Labels

Apply consistent labels so Kubernetes resources can be selected, grouped, and managed effectively.

Define Workloads as Code

Store Kubernetes YAML manifests in version control to improve consistency and change management.

Monitor Workload Status

Inspect Pods, workload resources, events, and logs to understand application health and troubleshoot issues.

Practice Scaling

Learn how replica counts and workload controllers help Kubernetes scale applications and maintain the desired state.

Next Step

Start managing Kubernetes workloads

Start with Pods and Deployments, then explore ReplicaSets, StatefulSets, DaemonSets, Jobs, and CronJobs to understand how Kubernetes manages different application workloads.