RousselTMLEARNING

Article · Kubernetes: From Discovery to Expertise

Deployment managers

Introduction #

In Kubernetes, workload controllers orchestrate and automate the life cycle of containerized applications. They handle scaling, redundancy and resource management for applications, enabling a scalable, fault-tolerant architecture.

Deployment #

Controller for stateless applications.

Overview #

A Deployment deploys and manages stateless applications. It maintains the desired number of running Pods, handles updates and rollbacks, and offers horizontal scaling options.

Use cases #

Used for web applications, APIs or any stateless service that can easily be replicated without depending on persistent storage.

Example #

apiVersion: apps/v1
kind: Deployment
metadata:
  name: example-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: example
  template:
    metadata:
      labels:
        app: example
    spec:
      containers:
      - name: example
        image: nginx

ReplicaSet #

Maintains the number of Pod replicas.

Overview #

A ReplicaSet maintains a constant number of identical Pods in the cluster. Deployments often rely on ReplicaSets to create and update Pods.

Use cases #

Used internally by Deployments to keep a stable number of Pods running.

StatefulSet #

For applications that need persistent storage.

Overview #

A StatefulSet is used for applications that need data persistence. Each Pod has a unique identity, preserved when the Pod is recreated, and is associated with a dedicated storage volume.

Use cases #

Databases, distributed file systems, or any application that needs a unique identifier or persistent state.

Example #

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: example-statefulset
spec:
  serviceName: "example"
  replicas: 3
  selector:
    matchLabels:
      app: example
  template:
    metadata:
      labels:
        app: example
    spec:
      containers:
      - name: example
        image: mysql

DaemonSet #

Ensures a Pod runs on every node.

Overview #

A DaemonSet ensures that a Pod runs on every node in the cluster. It is used for monitoring, log analysis or network maintenance tasks.

Use cases #

Monitoring agents, log collection, and any service that needs to be present on every node.

Example #

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: example-daemonset
spec:
  selector:
    matchLabels:
      name: example
  template:
    metadata:
      labels:
        name: example
    spec:
      containers:
      - name: example
        image: fluentd

Job #

Running one-off tasks.

Overview #

A Job runs Pods to complete a one-off task and stops when the task is finished. It is especially suited to data processing or maintenance scripts.

Use cases #

One-off tasks such as data analysis or batch processing.

Example #

apiVersion: batch/v1
kind: Job
metadata:
  name: example-job
spec:
  template:
    spec:
      containers:
      - name: example
        image: busybox
        command: ["echo", "Hello, Kubernetes!"]
      restartPolicy: Never

CronJob #

Scheduling recurring tasks.

Overview #

A CronJob schedules recurring tasks using crontab syntax. It is useful for backups, report generation or any periodic task.

Use cases #

Recurring tasks such as backups or data cleanup.

Example #

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: example-cronjob
spec:
  schedule: "*/5 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: example
            image: busybox
            command: ["echo", "Hello from CronJob"]
          restartPolicy: OnFailure

Choosing a workload controller #

  • For stateless applications: use a Deployment.
  • For stateful applications that need persistent identifiers: prefer a StatefulSet.
  • For tasks that must run on every node: choose a DaemonSet.
  • For one-off tasks: a Job is recommended.
  • For recurring tasks: a CronJob is ideal.

📄 Workload controllers →

My progress

  • ⏱ Estimated time : ≈ 16 min

Sign in to track your progress and take notes. Sign in

💬 Questions about this lesson

No questions yet: be the first to ask for help or share your configuration.

Ask a question about this lesson →

Course Glossary

Kubernetes

An open-source container orchestration engine (sometimes called K8s) for automating the deployment, scaling, and management of containerized applicati...

Recommended Articles

Package managers

The different package managers for Kubernetes and their advantages.

Kubernetes: Pods, ReplicaSets and Deployments (deploying and updating)

Master Kubernetes workloads: anatomy of a pod, ReplicaSet, Deployment, RollingUpdate and Recreate...

HAProxy in Kubernetes: the high-performance Ingress Controller

Discover in depth how HAProxy integrates with Kubernetes: direct-to-pod architecture, hot update ...

Kubernetes: exposing your applications (Services, Ingress and Gateway API)

Expose applications in Kubernetes: ClusterIP/NodePort/LoadBalancer Services, Ingress, IngressClas...

Container network security and Kubernetes networking

Secure the container network: how Docker and Kubernetes networking works, CNI, default-deny Netwo...

OpenTelemetry on Kubernetes: Operator, auto-instrumentation and Collector

Deploy OpenTelemetry on Kubernetes: Collector deployment modes (DaemonSet, Deployment, sidecar, S...

Jobs vs Serverless

A comparison between Kubernetes Jobs and the serverless model for running background tasks. An ex...

HAProxy as a Kubernetes Ingress Controller: the production guide

Learn how to use HAProxy as an Ingress Controller in Kubernetes: direct-to-pod architecture, TLS ...

Prometheus on Kubernetes and the Prometheus web interface

Deploy Prometheus on Kubernetes with kube-prometheus-stack (Prometheus Operator, ServiceMonitor, ...

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!