Kubernetes Workloads (Deployment, Jobs, CronJobs, StatefulSets, DaemonSets)

Deployment:

A deployment is a resource that manages the deployment of a set of identical pods. Deployments provide a declarative way to manage pod replicas and provide rolling updates and rollbacks to pods.

Kubernetes job:

  • A Kubernetes job creates one or more pods to run a task to completion.

  • Once the task is completed, the job is considered finished.

  • Jobs can be used for tasks that need to be run once or a finite number of times.

  • Jobs can be used for batch processing, parallel processing, or one-off tasks.

Kubernetes Cronjobs:

  • A Kubernetes CronJob is used to schedule recurring tasks in a Kubernetes cluster.

  • A CronJob creates jobs at specified intervals based on a cron expression.

  • CronJobs are useful for automating periodic tasks like backups, cleaning up old data, or generating reports.

  • CronJobs can be set to run on a specific schedule using a cron expression, similar to how cron works in Linux.

  • CronJobs can also specify time zones and other scheduling options.

StatefulSets:

  • A StatefulSet is a Kubernetes resource used to manage stateful applications, where each instance of the application has a unique network identity.

  • StatefulSets are used for applications that require stable and persistent storage, like databases or message queues.

  • It ensures that instances are started and stopped in a predictable manner.

  • StatefulSets can be used for scaling stateful applications horizontally or vertically.

  • Scaling a StatefulSet involves adding or removing instances in a specific order, and ensuring that persistent storage is maintained.

DaemonSets:

  • A DaemonSet is a Kubernetes resource used to manage stateless applications, where a copy of the application runs on every node in the Kubernetes cluster.

  • DaemonSets are used for applications that need to run on every node in the cluster, like monitoring agents or network proxies.

  • DaemonSets ensure that each node in the cluster has a copy of the application running, and can be used to scale stateless applications horizontally.

  • DaemonSets automatically create and delete instances of the application as nodes are added or removed from the cluster.