How should application types such as batch and stateful be configured on K8S?

This article was last updated on: February 7, 2024 pm

As we all know, Kubernetes (K8S) is better suited to runStatelessApplications, but except for stateless apps. We will also have many other application types, such as: stateful applications, batch processing, monitoring agents (running on each host), more complex applications (e.g. Hadoop ecosystem…). So can these applications run on the K8S? How to configure?

In fact, K8S has different operating methods for these. What you need to do is consider how your application type will affect the way it operates.

Kubernetes defines different types of workloads for different types of applications. To determine the right workload for your application, think of your application along these lines:

  • is to complete the task。 A typical example is an application that runs a batch of data at startup and exits after the batch execution is complete. The application may run periodically, such as monthly. For this type of application, appropriate Kubernetes (or OpenShift) container platform objects include: Jobs and CronJob  Object.

  • Long running all the time. For long-running applications, you can write Deployment。 (Of course, preferably stateless)

  • It needs to run on each node。 Some types of Kubernetes applications need to run on every master or worker in the cluster. DNS and monitored applications are typical examples of applications that need to run continuously on each node. You can use this type of application as DaemonSet Run. You can also run DaemonSet on a subset of eligible nodes based on node labels.

  • Complex applications, or full lifecycle management。 When you want to hand over an application so that other operators can easily use it, consider creating a **Operator** (Similar to HELM Charts, the difference is that HELM is only responsible for installation, and Operator has more lifecycle management in addition to installation). Operator lets you build intelligent apps, so it doesThings like backups and upgrades can be automated。 Used in conjunction with the Operator Lifecycle Manager (OLM), cluster administrators can expose operators to specific namespaces so that users in the cluster can run them. Examples are:


  • There are identity or number requirements。 Applications may have identity requirements or numbering requirements. For example, you might want to run no more, no less, exactly three instances of the application, and the instances are named01and2。 So**StatefulSet** is suitable for this application. StatefulSets are most useful for applications that require isolated storage, such as databases and Zookeeper clusters. To sum up, stateful applications choose StatefulSet .


The trend is that enterprise-level, complex, advanced stateful software is starting to favor Operators over Helm. Because operators provide more “self-healing” and “self-consistent” capabilities, they can achieve higher and higher levels of automation or even unhosting.


App Type K8S resource type Notes
Job, batch processing Jobs CronJob
Long-running stateless apps Deployment DeploymentConfig DeploymentConfigis unique to OpenShift
Long-running, stateless apps - High availability DeploymentRigaReplicaSetField
Apps that need to run on each node DaemonSet
Complex applications, or applications that require full lifecycle management Operator Helm ChartsAlso suitable for installing complex applications
Stateful apps StatefulSet

How should application types such as batch and stateful be configured on K8S?
Posted on
October 22, 2020
Licensed under