The example topology has a single primary server and multiple replicas, using asynchronous row-based replication. The example topology has a single primary server and multiple replicas, using asynchronous row-based replication. It is mainly designed to use for stateful apps. The dynamic provisioning. env. StatefulSet(stable-GA in k8s v1. 25. StatefulSets let you run stateful applications in Kubernetes. spec. unknown. SQL Server is a database application and thus mostly should be deployed as a StatefulSet workload type. type=charm. In our earlier example, we defined the environment variables with the StatefulSet YAML. service "nginx" created. By interpreting the documentation, it seems that it depends on the event. Unlike a Deployment, a StatefulSet maintains a sticky identity for each of their Pods. It will create three Pods named web-0,web-1,web-2. Manages the deployment and scaling of a set of Pods, and provides guarantees about the ordering and uniqueness of these Pods. We are on Kubernetes 1. Like a Deployment, a StatefulSet manages Pods that are based on an identical container spec. So by passing this flag to kubectl delete the Pods that are managed by. When to use a ReplicaSet. This page contains a list of commonly used kubectl commands and flags. Deploy and Manages the stateless application. StatefulSetには以下のような特徴がある。. Node affinity is a set of rules used by the scheduler to determine where a pod can be placed. In this example: A Deployment named nginx-deployment is created, indicated by the . Dynamic volume provisioning allows storage volumes to be created on-demand. StatefulSet. It manages the deployment and scaling of a set of Pods, and provides guarantee about. Definitely leverage a persistent volume for database. Understanding ReplicaSetsIt will trigger them all at once. A key aim of Services in Kubernetes is that you don't need to modify your existing application to use an unfamiliar service discovery mechanism. Let's take a closer look at when and where to use pods and deployments. To check the version, use the kubectl version command. Their purpose is to keep a set of identical pods running and upgrade them in a controlled way. The following provides an example of deploying a single Kubernetes MySQL instance using Trident. Without dynamic provisioning, cluster administrators have to manually make calls to their cloud or storage provider to create new storage volumes, and then create PersistentVolume objects to represent them in Kubernetes. Authors: Mahamed Ali (Rackspace Technology) The Kubernetes project runs a community-owned image registry called registry. In Prefect Cloud, go to Blocks, hit the + button, and select the Kubernetes Job block. Let’s use the UI for our first example. The Reclaim Policy is used to determine the actions that need to be taken by the storage backend on deletion of the PV. Compare Kubernetes StatefulSet vs. replicas integer: Total number of non-terminated pods targeted by this deployment (their labels match the selector). When you use a StatefulSet, Kubernetes terminates Pods in the opposite order to their creation. Statefulsets. In Persistent Volume Claims under Storage, you can see the ClickHouse Cluster components are using persistent volumes. These pods are created from the same spec, but are not interchangeable: each has a persistent identifier that it maintains across any. Unlike a Deployment, a StatefulSet maintains a sticky identity for each of their Pods. Kubernetes StatefulSet is the workload API object used to manage stateful applications. To revert the deployment to the previous working version, use the rollout undo command: kubectl rollout undo statefulset/dbc1 -n mysql1 The output is similar to the following:StatefulSet and deployment controllers. These are applications that can easily scale. We like to dynamically assign a value (that's derived from the ordinal index) to the pod's label and later. To check your version of Kubernetes, run kubectl version. When you use a StatefulSet, Kubernetes terminates Pods in the opposite order to their creation. Statefulset es un recurso que controla y gestiona en kubernetes uno o más Pods, pero entonces por qué no usar un Deployment te estarás preguntando?, entonces antes de continuar es mejor que veas las diferencias entre Stateful y Stateless en una. Kubernetes deployments vs. StatefulSet. kubectl apply -f <name> to recreate the StatefulSet. The StatefulSet manifest should feel familiar—it looks a lot like a Deployment manifest! Instead of the volume field under a Deployment’s template spec, we define a VolumeClaimTemplate under the overall StatefulSet spec to describe how the workload will consume storage. e: class-name and the pod created will be class-name-0 and you can replace the _ by -. Above is one example of a Deployment Strategy called Blue/Green. Of course, the scaling depends on the app you are deploying. kubectl delete sts --cascade=orphan <name> to delete the StatefulSet and leave its pods. updateStrategy is left unspecified. Before you begin You need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your. . Version the ConfigMap. If you look at web_stateful. The --region flag specifies a regional three-zone cluster, and --num-nodes specifies one Kubernetes worker node in each zone. template. As Crou wrote, it is possible to do this operation with kubectl scale statefulsets <stateful-set-name> but this is an imperative operation and it is not recommended to do imperative operations in a production environment. DaemonSets, StatefulSets and Deployments are three ways to deploy workloads in Kubernetes. Scaling a StatefulSet refers to increasing or decreasing the number of replicas. Step 3: Create and deploy the StatefulSet. Check. This post talks about recent updates to the DaemonSet and StatefulSet API objects for Kubernetes. StatefulSet. Because the replicas field of the nacos StatefulSet is set to 2, In the cluster file only two nacos address. We can now deploy the etcd cluster, which will be a StatefulSet with 3 replicas and two Services, one for internal peer communication between the instances as headless service and another for accessing the cluster externally through the API. template. 3. Kubernetes is a powerful container orchestration tool that provides a variety of resources. Resource objects typically have 3 components: Resource ObjectMeta: This is metadata about the resource, such as its name, type, api version, annotations, and labels. This page shows how to run a replicated stateful application using a StatefulSet. Let’s now create the Deployment using the kubectl apply command: $ kubectl apply -f deployment. 0. Pod に障害が発生し、オートヒーリングを実施した際にも、同一のPVを引き続き mount. 若一個 statefulset 包含了 n 個 replica,那每一個 pod 都會被分配到一個獨立的索引,從 0 ~ n-1 ,即使. In contrast, annotations are not used to identify and select objects. If you require stable, data restoring operation to your application, you can use a StatefulSet in Kubernetes. Example code for HPA: Deployment is a resource to deploy a stateless application, if using a PVC, all replicas will be using the same Volume and none of it will have its own state. 6. summary, it is possible to set min / max replicas for a statefulset using HPA. Statefulset vs Deployment; StatefulSet and Deployment are both Kubernetes resources used for managing containerized applications, but they differ in. Use kubectl to scale StatefulSets; kubectl scale sts nacos --replicas=3kubernetes, docker, k8s, cluster, kubectl, Workloads, DaemonSet, CronJob, StatefulSet, Job. Deployment. apps. Like a Deployment, a StatefulSet manages Pods that are based on an identical container spec. This name will become the basis for the ReplicaSets and Pods which are created later. As a result, when the deployment starts to scale, unready applications might receive traffic. RollingUpdate: The RollingUpdate update strategy implements automated, rolling update for the Pods in a StatefulSet. Updates are versioned and you can revert to any previously known state of a Deployment. Both Pod and Deployment are full-fledged objects in the Kubernetes API. Pods created by a StatefulSet have a unique and stable network identity. (PV) controllers and architectures like DaemonSet and StatefulSet which remain in operation even when Kubernetes scales and provisions cluster resources and ensures. yaml file, you will find a snippet around how we are deploying a stateful application. affinity. Kubectl autocomplete BASH source <(kubectl completion bash) # set up autocomplete in bash into the current shell, bash-completion package should be installed. Create a MySQL Deployment. This task shows how to scale a StatefulSet. Deployments in k8s do not keep state in their Pods by assuming the application is stateless. Dynamic volume provisioning allows storage volumes to be created on-demand. 0}. It worked as expected and both the prometheus pods got restarted. apiVersion: apps/v1 kind: StatefulSet metadata: name: web # this will be used as prefix in pod name spec: serviceName: "nginx" replicas: 2 # specify number of pods that should be running selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: k8s. –In the previous blog we created a stateless application, deployed with K8s resource Deployment, which allows one to replicate the application, but where data is lost when Pods are restarted, meaning there were no data consistency. DaemonSet vs. This ensures it’ll be postgres-2 that’s destroyed first. I assume that you need this for a stateful workload, a workload that e. Storage. yml. Storage classes can define properties of storage systems. Expose MySQL to other pods in the cluster at a known DNS. Check if the Cassandra nodes are up,. spec. 5. It is clearly explained in the documentation under Deleting the Statefulset: Deleting a StatefulSet through kubectl will scale it down to 0, thereby deleting all pods that are a part of it. We are going to need the affinity/anti-affinity settings. You can also run EKS on Outposts for on. Features and tools, such as Kubernetes Services, Jobs, and taints and tolerations, help admins manage pod and node deployment. Product. Comme un Déploiement, un StatefulSet gère des Pods qui sont basés sur une même spécification de conteneur. See Writing a Deployment Spec for more details. apiVersion: apps/v1 kind: StatefulSet metadata: name: web # this will be used as prefix in pod name spec: serviceName: "nginx" replicas: 2 # specify number of pods that should be running selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec:. Verifying Successful Cassandra Deployment. It lets you update a set of pods with no downtime, by incrementally replacing pod instances with new instances that run a new version of the application. Using volumeClaimTemplates, each replica will get a unique PersistentVolumeClaim with statefulset whereas all replicas would share the PersistentVolumeClaim with a deployment. zk-0 zk-1 zk-2See StatefulSet vs. spec. Kubernetes Replication Controller vs Deployment Deployments are intended to replace Replication Controllers. Deployment vs Statefulset. The actual Pod creation is handled by the StatefulSet controller in Kubernetes. See Writing a Deployment Spec for more details. To get the name just read the environment variable HOSTNAME. 1. g. Note: These instructions are for Kubernetes v1. En esta entrada vamos a tratar sobre aplicaciones Stateful en Kubernetes – Statefulset, el cual es un tipo de recurso que nos ofrece Kubernetes. kubectl api-resources -o wide | grep -i deployment will provide the relevant information. This makes it easier to manage and maintain each component. This page shows how to run a replicated stateful application using a StatefulSet. In a stateful containerized application, data must be persistent, retained and easy to access outside the application. 安定したネットワーク識別子. A StatefulSets are Kubernetes objects used to consistently deploy stateful application components. yml2 Answers. As the name suggest the statefulsets are specifically used to make sure the app state is saved by each running pod. A StatefulSet is a workload API object for managing stateful applications. Kubernetes persistent volumes (PVs) are a unit of storage provided by an administrator as part of a Kubernetes cluster. Kubernetes provides a basic resource called Pod. Several other StatefulSet features also apply to this example: StatefulSet vs Deployment In Kubernetes, a Deployment is a workload resource object that lets you configure the lifecycle of pods in the cluster. spec. 部署、扩展、更新、删除都要有顺序 2. 5, we’ve moved the feature formerly known as PetSet into beta as StatefulSet. k8s securityContext bypass. It is rather unlikely that you will ever need to create Pods directly for a production use-case. Like. As with StatefulSet creation, the StatefulSet controller created each Pod sequentially with respect to its ordinal index, and it waited for each Pod's predecessor to be Running and Ready before launching the subsequent Pod. 其實是分別由以下三種資訊所組成:. Before proceeding, make yourself familiar with the considerations. Description. If. This page shows you how to run a single-instance stateful application in Kubernetes using a PersistentVolume and a Deployment. Manages the deployment and scaling of a set of Pods, and provides. Statefulsets. You can only specify minDomains in conjunction with whenUnsatisfiable: DoNotSchedule. As with all other Kubernetes API objects, a ReplicaSet needs the apiVersion, kind, and metadata fields. Like a Deployment, a StatefulSet manages Pods that are based on an identical container spec. It specifies that there should be three replicas of the Deployment and that each pod should be labeled with app: nginx. Each pod has a persistent identifier, that it maintains across any. Before you begin This is a fairly advanced task and has the potential to violate some of the properties inherent to StatefulSet. Kubernetes has become the de-facto orchestration tool and initially it was supporting stateless applications, but stateful (data-driven) applications are very common and are critical to almost all the businesses. This means that each Pod in a StatefulSet has a stable network identity and persistent storage, which are essential for. We explore these features using Apache ZooKeeper and Apache Kafka StatefulSets and a Prometheus node exporter. 目前看来有点本末倒置,不过不. The three most common are: Rolling update strategy: Minimizes downtime at the cost of update speed. kubectl get pods NAME READY. A key aim of Services in Kubernetes is that you don't need to modify your existing application to use an unfamiliar service discovery mechanism. spec. kubectl create namespace database. Each Pod in a StatefulSet derives its hostname from the name of the StatefulSet and the ordinal of the Pod. Next, add the following lines to the deployment pipeline files. DaemonSet Kubernetes has several ways to deploy applications, including deployments, DaemonSets and StatefulSets. Pod Management. In this article. Meaning you can create a Replica set containing only one Pod specifying to run only one instance of that Pod. spec: serviceAccountName: build. The manifest files do not have the namespace added to them. Define the application in YAML format using kind: StatefulSet. network issue), for Deployment, a new Pod will be created on a different node (to follow your desired 1 replica), but for StatefulSet it will make sure to terminate the existing Pod before creating a new, so that there are never more than 1 (when you have 1 as desired number of replicas). Run a Stateless Application Using a Deployment; Run a Single-Instance Stateful Application; Run a Replicated Stateful Application; Scale a StatefulSet; Delete a StatefulSet; Force Delete StatefulSet Pods; Horizontal Pod Autoscaling; HorizontalPodAutoscaler Walkthrough; Specifying a Disruption Budget for your. As you will need to specify 'podSpec' in Deployment as well, you should be able to configure the service account in the same way. nodeAffinity field (if specified) is taken into consideration by the DaemonSet controller when evaluating the eligible nodes, but is replaced on the created Pod with the node. Nota: Los StatefulSets son estables (GA) en la versión 1. There is an entry for resources in my statefulset yaml and CPU limit is set to 1 and request to 0. (SSOT) for all of your k8s. The example above will create three Pods named web-0,web-1,web-2. The answer is in your first log: The StatefulSet "cassandra" is invalid: spec: Forbidden: updates to statefulset spec for fields other than 'replicas', 'template', and 'updateStrategy'. The application is MySQL. As the name suggest the statefulsets are specifically used to make sure the app state is saved by each running pod. When a StatefulSet's . Introduction to autoscaling in k8s. Kubernetes administrators define classes of storage, and then pods can dynamically request the specific type of storage they need. If we need to update the application to a new version, we can change the fields in the Deployment YAML file. The deployment process for Deployment objects is driven by a controller loop, in contrast to DeploymentConfig objects which use deployer pods for every new rollout. I'm using Logstash on Kubernetes and use the official Helm chart at this link. Note: This is not a production configuration. When pods run as part of a StatefulSet, Kubernetes keeps state data in the persistent storage volumes of the StatefulSet, even if the pods shut down. StatefulSet Kubernetes | Understand what StatefulSet in Kubernetes is and how it worksUsing StatefulSet in practice 🙅🏼♀️ create the MongoDB replica set, run these two commands: kubectl apply -f googlecloud\_ssd. Author: Deepak Kinni (VMware) PersistentVolume (or PVs for short) are associated with Reclaim Policy. Several other StatefulSet features also apply to this example:StatefulSet vs Deployment. Resource Objects. 1. A Replica set is used to ensure that a specific set of Pods is running at all times. io/ssd created Deploy etcd cluster. Update Deployment Strategies. PersistentVolumes and StatefulSets are the main approaches for running stateful applications in Kubernetes. affinity. The new pod will automatically spin up with correct configuration. Statefulset vs Deployment in k8s. Network identities: Kubernetes StatefulSet provides stable network identities for each pod, while Deployment doesn’t. Since Elasticsearch maintains state, we need to use StatefulSet which is a deployment that can maintain state. kubectl rollout undo deployment/<deployment name> – Rollback a. ; When the number of eligible domains with match topology keys is less than minDomains, Pod topology spread treats global minimum as 0, and then the calculation of skew is performed. For a rolling update, the Deployment's maxUnavailable will be in effect, even if the PodDisruptionBudget specifies a smaller value. - Storage: As many VolumeClaims as requested. So, for example, Kubernetes will only create example-statefulset-5 after example-statefulset-4 is up and running. Otherwise you can use Deployments with multiple pods online for your shards. 1. The termination of Pods is performed in reverse {N-1. In K8s, StatefulSets are a higher-level abstraction over pods that provide guarantees about the ordering and uniqueness of pods. The last section of the manifest defines our StatefulSet. September 22, 2021 Topics: Cloud Volumes ONTAP Elementary 8 minute read Kubernetes What Is Kubernetes StatefulSet? A StatefulSet is a Kubernetes API object for managing stateful application workloads. You can use kubectl create configmap with the --from-literal argument to define a literal value from the command line: kubectl create configmap special-config --from-literal=special. In this. It manages the deployment and scaling of a set of Pods, and provides guarantee about the ordering and uniqueness of these Pods. Un StatefulSet es el objeto de la API workload que se usa para gestionar aplicaciones con estado. Compare Kubernetes StatefulSet vs. 2. func NewForConfigAndClient (c * rest. yaml storageclass. In contrast to that, the Pods deployed by StatefulSet component are NOT identical and deployment is more complex. This controller monitors the state of Kubernetes Deployments, the most common approach to deploying a workload in Kubernetes. Full k8s cluster consists of 4–5 services on the control plane and two on worker nodes. Statefulsets. When a deployment is created, Kubernetes builds pods to host application. After reverting the configuration, you must also delete any Pods that StatefulSet had already attempted to run with the bad configuration. First, the (1) pod comes up, initialized, and then settles into a “ready” state. 5 or later. When we scale the StatefulSet from 1 replica to 3, the StatefulSet controller starts to incrementally deploy new (missing) pods, one at a time. So you will have a statefulset definition similar to this: apiVersion: apps/v1 kind: StatefulSet metadata: name: myset spec: replicas: 3. The node does not have control over the placement. Moreover, if at any point one of the replicas fails to start, the whole process will stop. podManagementPolicy. This is required by RabbitMQ for clustering, and as mentioned in the Kubernetes documentation, has to be created before the Stateful Set. StatefulSet metadata: name: cassandra labels: app:. Every Kubernetes object also has a UID that is unique across your whole cluster. But it differs from a Deployment in that it is more suited for stateful apps. Kubernetes provides a basic resource called Pod. StatefulSetには以下のような特徴がある。. This page shows how to delete Pods which are part of a stateful set, and explains the considerations to keep in mind when doing so. For example, if you have 3 nodes, it will schedule 3. Logs stored persistently in storage, don't represent the state of the application. allows you to set environment variables for a container by referencing either a ConfigMap or a Secret. This comes at a cost of slow scale ups and. StatefulSet. You do not associate the volume with any Pod. Kubernetes is an open-source platform that is designed to deploy and scale container operations. StatefulSetSpec. The deployment is made up of 2 Nginx web servers; both of them are connected to a persistent volume. But unlike a regular deployment, it allows you to specify the order and dependencies of the deployment to. It offers a framework to manage clusters of hosts running Linux containers,. The generation observed by the deployment controller. Deployments with three replicas all schedule simultaneously. Deploying a Stateful Application Using Kubernetes Statefulset. From there, the StatefulSet Controller handles the. Deployment vs StatefulSet. I want to deploy a single Pod on a Node to host my service (like GitLab for the example). All of the other parts are ready and we will just plug in the engine and we will be ready to hit the road. Autoscaling is a process that dynamically scales up or down any components of your architecture. This application is a replicated MySQL database. If we execute the commands: kubectl get sts and kubectl get pods -l app=mysql , we see the cluster deployed. deployment daemonset Kubernetes (K8s) is one of the popular open-source container orchestration systems for automating deployment, scaling, and management. if the node becomes unreachable (e. This comes at a cost of slow scale ups and scale downs for. First, we run the service template : kubectl apply -f service. The user can specify a different scheduler for the Pods of the DaemonSet, by setting the . StatefulSet workloads. 04 Sep 2023 · 11 min read. StatefulSets and Deployments are two Kubernetes API objects used to manage sets of identical Pods. as with deployments. Kubernetes offers Deployment strategies that allow you to update in a variety of ways depending on the needs of the system. g. Like a Deployment, a StatefulSet manages Pods that are based on an identical container spec. Kubernetes Deployment vs. In one terminal, watch the StatefulSet's Pods: Yes, Statefulset is the way to go if the pods need to have their identity defined in some way. It doesn't necessarily refer to the deployment of applications or services. how=very --from-literal=special. A StatefulSet can use a Headless Service to control the. You, now taking the role of a developer / cluster user, create a. 5 In the latest release, Kubernetes 1. I have tested its working by autoscaling one of my Deployment. A stateful application requires pods with a unique identity (for example, hostname). Some of the key features of StatefulSets are as follows: 1. All three of these are defined via YAML configuration, are created as an object in the cluster, and are then managed on an ongoing basis by a Kubernetes controller. The metadata in an annotation can be small or large, structured or unstructured, and can. $ export MYSQLPOD. I tested this on kubernetes 1. The deployment is made up of 2 Nginx web servers; both of them are connected to a persistent volume. The output of the describe command in this example is the following: Name: nginx-app1. Deployment. 1. Rather, a deployment is a file that defines a pod's desired behavior or characteristics. A StatefulSet lets you manage one or more Pods – all running the same application code – where the Pods rely on having a distinct identity. It makes sense also as each Redis instance relies on a configuration file that keeps track of other cluster instances and their roles. name of the ReplicaSet is part of the basis for naming those Pods. Kubernetes or K8s is an open-source orchestration system for containerized applications that helps in automating software deployment, management and scaling. To create a StatefulSet resource, use the kubectl apply command. The hostnames take the form of <statefulset name>-<ordinal index>. io to host its container images. spec. This way you could either, name the stateful-set according to the classes, i. This article will walk you through how to deploy NFS Subdir External Provisioner to the k8s cluster and create the PV using the. Statefulset vs Deployment. StatefulSets manage the creation, scaling, and deletion of pods. A workload API object that manages stateful applications, such as databases. Introduction A StorageClass provides a way for administrators to describe the "classes" of storage they offer. template. Before you begin You need to have a Kubernetes cluster, and the kubectl. 23 introduced a new, alpha-level policy for StatefulSets that controls the lifetime of PersistentVolumeClaims (PVCs) generated from the StatefulSet spec template for cases when they should be deleted automatically when the StatefulSet is deleted or pods in the StatefulSet are scaled. Let’s now create the Deployment using the kubectl apply command: $ kubectl apply -f deployment. Replica sets provide redundancy and high availability and are the basis for all production deployments. But still for the alertmanager statefulset, only 1 pod is getting restarted. When a pod instance managed by a StatefulSet disappears (because the node the pod was running on has failed, it was evicted from the node, or someone deleted the pod object manually), the StatefulSet makes sure it’s. Each Pod in the StatefulSet gets a name generated by suffixing the pod ordinal to the StatefulSet name. kubectl basics. Ordinal Index. 1. k8s. 2. StatefulSets. ; A Persistent Volume. spec. 每个pod都有自己存储,所以都用volumeClaimTemplates,为每个pod都生成一个自己的存储,保存自己的状态 3. also during upgrades and. One pod should be able to reach other pods with well-defined names. The Hitchhiker’s Guide to the Galaxy is popular around Prefect. 9) is a Kubernetes resource used to manage stateful applications. Scaling a StatefulSet refers to increasing or decreasing the number of replicas. Overview of StatefulSets. You can use kubectl create configmap with the --from-literal argument to define a literal value from the command line: kubectl create configmap special-config --from-literal=special. What it appears is that if I set an initialDelaySeconds on a startup probe or leave it 0 and have a single failure, then the probe doesn't get run again for a while and ends up with atleast a 1-1. If you don’t specify the namespace, it gets deployed in the default namespace. From K8S Docs. Stable Network ID. Unlike a Deployment, a StatefulSet maintains a. For example, you can only have one Pod named myapp-1234 within the same namespace, but you can have one Pod and one Deployment that are each named. The common format of a kubectl command is: kubectl action resource This performs the specified action (like create, describe or delete) on the specified resource (like node or deployment). 只能用StatefulSet: 最近在微软的aks平台上部署服务,由于Deployment在scale的时候需要动态申请volume,采取使用volumeClaimTemplates属性的方式来申请,当前Deployment对象(1. In this article, we’ll compare Kubernetes Deployment vs Kubernetes StatefulSet, explore their differences, and help you decide which one to use for your application. Pods are created and terminated in a predictable order, ensuring orderly scaling and rolling updates. StatefulSets will ensure the same PersistentVolumeClaim stays bound to the same Pod throughout its lifetime. ReplicaSet vs. conditions[1): unknown field "lastUpdateTime" in io. Editor’s note: this post is part of a series of in-depth articles on what's new in Kubernetes 1. A Pod (as in a pod of whales or pea pod) is a group of one or more containers, with shared storage and network resources, and a specification for how to run the containers. First, we run the service template : kubectl apply -f service. If the StatefulSet is scaled down to one replica, mysql-3 is guaranteed to exit first, followed by mysql-2. Each object in your cluster has a Name that is unique for that type of resource. StatefulSet. How to run stateful applications in Kubernetes. In this article, we’ll take a look at the differences between Deployment and StatefulSet and when you should use one over the other. This name will become the basis for the ReplicaSets and Pods which are created later. exe create deployment my-nginx --image nginx.