ops0ops0

Workloads

Manage all Kubernetes workload types: StatefulSets, DaemonSets, Jobs, CronJobs, and ReplicaSets.

Workload Types

StatefulSets
Ordered, stable pods with persistent identities (databases, queues)
DaemonSets
Run one pod per node (monitoring agents, log collectors)
Jobs
Run pods to completion (batch processing, migrations)
CronJobs
Scheduled jobs (backups, reports, cleanup tasks)

StatefulSets

Manage stateful applications with ordered pod creation and stable network identities.

StatefulSet Features

FeatureDescription
Ordered DeploymentPods created sequentially (pod-0, pod-1, pod-2)
Stable Network IDsEach pod gets predictable DNS name
Persistent StoragePVCs follow pod across reschedules
Ordered ScalingScale up/down maintains order

Viewing StatefulSets

ColumnDescription
NameStatefulSet name
NamespaceKubernetes namespace
ReplicasDesired / Current / Ready
AgeTime since creation

StatefulSet Details

  • Pod list showing ordered names (pod-0, pod-1, pod-2)
  • PVC bindings per pod
  • Service association
  • Update strategy (RollingUpdate or OnDelete)

Scaling StatefulSets

  1. Open StatefulSet detail
  2. Adjust replica count
  3. Click "Scale"
  4. Pods added/removed in reverse order

Scaling Behavior:

  • Scale up: Creates pod-N, waits for Ready, creates pod-N+1
  • Scale down: Deletes pod-N, waits for termination, deletes pod-N-1

Restarting StatefulSets

Perform rolling restart:

  1. Click "Restart"
  2. Pods restart in reverse order (highest to lowest)
  3. Each pod must be Ready before next restarts

DaemonSets

Run exactly one pod on every node (or subset of nodes with selectors).

DaemonSet Features

FeatureDescription
Node CoverageOne pod per node automatically
Automatic SchedulingNew nodes get pod automatically
Node SelectorsTarget specific node labels
Tolerate TaintsRun on tainted nodes (e.g., master)

Viewing DaemonSets

ColumnDescription
NameDaemonSet name
NamespaceKubernetes namespace
DesiredPods that should exist
CurrentPods currently running
ReadyPods passing readiness checks
NodesNodes covered

DaemonSet Details

  • Pod distribution across nodes
  • Node selector rules
  • Update strategy (RollingUpdate or OnDelete)
  • Tolerations configured

Common DaemonSet Uses

Use CaseExample
Log CollectionFluentd, Filebeat running on every node
MonitoringNode exporter, metrics collectors
NetworkingCNI plugins, kube-proxy
SecuritySecurity agents, compliance scanners

Restarting DaemonSets

Rolling restart across all nodes:

  1. Click "Restart"
  2. Pods restart node-by-node
  3. Max unavailable controls rollout speed

Jobs

Run pods to completion for batch processing tasks.

Job Features

FeatureDescription
CompletionsNumber of successful pod completions required
ParallelismNumber of pods running concurrently
RetriesAutomatic restart on failure (backoffLimit)
TTL After FinishedAuto-delete completed jobs

Viewing Jobs

ColumnDescription
NameJob name
NamespaceKubernetes namespace
CompletionsSuccessful / Desired
DurationTime since start or completion time
AgeTime since creation

Job Details

  • Pod list (completed and failed pods)
  • Completion status
  • Active pods
  • Failed pod count
  • Conditions (Complete, Failed)

Job Status

StatusMeaning
RunningPods actively executing
CompleteRequired completions reached
FailedExceeded backoff limit

Deleting Jobs

  1. Click "Delete" on job
  2. Confirm deletion
  3. Job and all pods removed

Note: Completed job pods remain until job is deleted (for log inspection).


CronJobs

Schedule recurring jobs using cron syntax.

CronJob Features

FeatureDescription
Cron ScheduleStandard cron syntax (0 2 * * *)
Concurrency PolicyAllow, Forbid, or Replace concurrent jobs
SuspendPause scheduling without deleting
Job HistoryKeeps last N successful and failed jobs

Viewing CronJobs

ColumnDescription
NameCronJob name
NamespaceKubernetes namespace
ScheduleCron expression
SuspendWhether scheduling is paused
Last ScheduleTime of last job creation
Active JobsCurrently running jobs

CronJob Details

  • Schedule and next run time
  • Job history (last 5 runs)
  • Active jobs
  • Concurrency policy
  • Suspend status

Triggering CronJobs Manually

Run job immediately without waiting for schedule:

  1. Click "Trigger Now"
  2. New job created with timestamp suffix
  3. Job runs like scheduled execution

Suspending CronJobs

Pause scheduling temporarily:

  1. Click "Suspend"
  2. No new jobs created
  3. Active jobs continue running
  4. Click "Resume" to restart scheduling

Common CronJob Schedules

ScheduleDescription
0 2 * * *Daily at 2:00 AM
0 */6 * * *Every 6 hours
0 0 * * 0Weekly on Sunday at midnight
0 0 1 * *Monthly on the 1st
*/15 * * * *Every 15 minutes

ReplicaSets

Manage identical pod replicas (usually controlled by Deployments).

ReplicaSet Features

FeatureDescription
Pod ReplicasMaintains desired number of pod copies
Label SelectorIdentifies pods to manage
Owner ReferencesUsually owned by Deployment

Viewing ReplicaSets

ColumnDescription
NameReplicaSet name (usually deployment-hash)
NamespaceKubernetes namespace
ReplicasDesired / Current / Ready
DeploymentParent deployment (if any)
AgeTime since creation

When to Use

Deployments create ReplicaSets automatically - you rarely manage ReplicaSets directly.

Direct ReplicaSet use cases:

  • Custom controllers
  • Advanced deployment strategies
  • Legacy applications migrating from ReplicationControllers

Scaling ReplicaSets

  1. Open ReplicaSet detail
  2. Adjust replica count
  3. Click "Scale"

Warning: If owned by Deployment, Deployment will override this change.


Example: Managing a StatefulSet

StatefulSet Overview

StatefulSet: postgresql
Namespace:   production
Replicas:    3/3
Strategy:    RollingUpdate

Pod List

PodStatusPVCReadyAge
postgresql-0Runningdata-postgresql-0True45d
postgresql-1Runningdata-postgresql-1True45d
postgresql-2Runningdata-postgresql-2True30d

Scaling from 3 to 5

Scale-Up Process:

10:30:00  Scaling postgresql from 3 to 5 replicas
10:30:01  Creating pod postgresql-3
10:30:02  Creating PVC data-postgresql-3
10:30:15  Pod postgresql-3 Running and Ready
10:30:16  Creating pod postgresql-4
10:30:17  Creating PVC data-postgresql-4
10:30:30  Pod postgresql-4 Running and Ready
10:30:30  StatefulSet successfully scaled to 5 replicas

After Scaling

StatefulSet: postgresql
Namespace:   production
Replicas:    5/5
Pods:        postgresql-0 (Running)
             postgresql-1 (Running)
             postgresql-2 (Running)
             postgresql-3 (Running)
             postgresql-4 (Running)

Example: DaemonSet Monitoring

DaemonSet Overview

DaemonSet: node-exporter
Namespace: monitoring
Nodes:     12
Desired:   12
Current:   12
Ready:     12

Node Distribution

NodePodStatusReadyCPUMemory
node-1node-exporter-abc12RunningTrue50m100Mi
node-2node-exporter-def34RunningTrue48m98Mi
node-3node-exporter-ghi56RunningTrue52m102Mi
..................

Rolling Restart

Restart Process:

10:45:00  Restarting DaemonSet node-exporter
10:45:01  Terminating pod on node-1
10:45:15  New pod on node-1 Running and Ready
10:45:16  Terminating pod on node-2
10:45:30  New pod on node-2 Running and Ready
...
10:50:00  All 12 pods restarted successfully

Example: CronJob Backup

CronJob Configuration

CronJob:     database-backup
Namespace:   production
Schedule:    0 2 * * *  (Daily at 2:00 AM)
Suspend:     False
Concurrency: Forbid

Job History

JobStart TimeCompletionDurationStatus
database-backup-202401152024-01-15 02:00:002024-01-15 02:15:0015mComplete
database-backup-202401142024-01-14 02:00:002024-01-14 02:12:0012mComplete
database-backup-202401132024-01-13 02:00:002024-01-13 02:18:0018mComplete
database-backup-202401122024-01-12 02:00:00--Failed

Manual Trigger

Trigger backup immediately for testing:

  1. Click "Trigger Now" on database-backup
  2. New job created: database-backup-manual-20240115-103000
  3. Job runs with same configuration as scheduled execution

Result:

Job: database-backup-manual-20240115-103000
Status: Running
Active Pods: 1
Duration: 5m 30s

Troubleshooting

StatefulSet Pod Stuck
Check PVC binding status. StatefulSets wait for PVCs to bind before creating pods. Verify StorageClass exists and has available capacity.
DaemonSet Not Scheduling
Check node taints and DaemonSet tolerations. Verify node selectors match actual node labels. Review pod events for scheduling failures.
Job Failed
Check pod logs for failure reason. Verify backoffLimit is appropriate. Review pod events for resource constraints or image pull issues.
CronJob Not Running
Verify CronJob is not suspended. Check cron schedule syntax is valid. Review CronJob events for scheduling errors or concurrency policy conflicts.
Best Practices
StatefulSets - Use headless services for stable network identities, set appropriate update strategies
DaemonSets - Configure resource limits to prevent node exhaustion, use update strategies carefully
Jobs - Set appropriate backoffLimit and activeDeadlineSeconds to prevent infinite retries
CronJobs - Use Forbid concurrency policy for tasks that shouldn't overlap, set job history limits
ReplicaSets - Use Deployments instead for most use cases, only manage directly for advanced scenarios