Controllers

  • A controller tracks at least one Kubernetes resource type.
  • They have a spec field that represents the desired state.

Controller benefits

  • Application reliability
  • Scaling
  • Load Balancing

Controller types

ReplicaSets

It Ensures that a specified number of replicas for a pod are running at all times.

Deployment

Deployment controller provides declarative updates for pods and ReplicaSets. It is defined as creating new ReplicaSets or replacing existing ones. It is blueprint for pods.

Use cases:

  • Pod Management
  • Scaling a ReplicaSet
  • Pause and Resume
  • Deployment status

ReplicationController is an early implementation of Deployments AND ReplicaSets

DaemonSets

It ensures that all nodes run a copy of a specific pod.
As nodes are added/removed from the cluster, a DaemonSet will add or remove the required pods.

Use Cases:

  • Run a single log aggregator or monitoring agent on a node

Jobs

It is a supervisor process for pods carrying out batch jobs.
Jobs are a construct that run a pod once and then stop. Unlike pods/deployments, output of Jobs is kept around until you remove it.

Use Cases:

  • They are used to run individual processes that run once and complete successfully

CronJobs

  • As cron job runs periodically
  • To stop a CronJob you can edit the YAML by kubectl edit cronjobs/hellojob and set the suspend to true

Services

It provides communication between one set of deployments with another.

Types:

  • Internal Service: IP is only reachable within cluster
  • External Service: endpoint available through node IP:PORT (called NodePort)
  • Load Balancer: exposes application to the internet with a load balancer (available with the cloud provider)