N
InsightHorizon Digest

What is StatefulSet

Author

Joseph Russell

Updated on April 13, 2026

StatefulSet is the workload API object used to manage stateful applications. Manages the deployment and scaling of a set of Pods, and provides guarantees about the ordering and uniqueness of these Pods. Like a Deployment, a StatefulSet manages Pods that are based on an identical container spec.

What is the difference between StatefulSet and deployment?

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. Statefulsets is used for Stateful applications, each replica of the pod will have its own state, and will be using its own Volume.

How do you describe StatefulSet?

Overview. StatefulSets represent a set of Pods with unique, persistent identities and stable hostnames that GKE maintains regardless of where they are scheduled. The state information and other resilient data for any given StatefulSet Pod is maintained in persistent disk storage associated with the StatefulSet.

When should I use StatefulSet?

  1. A Redis pod that has access to a volume, but you want it to maintain access to the same volume even if it is redeployed or restarted.
  2. A Cassandra cluster and have each node maintain access to its data.
  3. A webapp that needs to communicate with its replicas using known predefined network identifiers.

How does Kubernetes StatefulSet work?

StatefulSets work much like a Deployment does. They contain identical container specs but they ensure an order for the deployment. Instead of all the pods being deployed at the same time, StatefulSets deploy the containers in sequential order where the first pod is deployed and ready before the next pod starts.

What is k8s DaemonSet?

A DaemonSet ensures that all eligible nodes run a copy of a Pod. Normally, the node that a Pod runs on is selected by the Kubernetes scheduler. However, DaemonSet pods are created and scheduled by the DaemonSet controller instead. … Pod preemption is handled by default scheduler.

How do I get a StatefulSet?

Creating a StatefulSet You will need to use two terminal windows. In the first terminal, use kubectl get to watch the creation of the StatefulSet’s Pods. In the second terminal, use kubectl apply to create the headless Service and StatefulSet defined in web.

What is a PVC Kubernetes?

A PersistentVolumeClaim (PVC) is a request for storage by a user. It is similar to a Pod. Pods consume node resources and PVCs consume PV resources. Pods can request specific levels of resources (CPU and Memory).

What is the purpose of pods in Kubernetes?

Pods are the smallest, most basic deployable objects in Kubernetes. A Pod represents a single instance of a running process in your cluster. Pods contain one or more containers, such as Docker containers. When a Pod runs multiple containers, the containers are managed as a single entity and share the Pod’s resources.

How do I scale down StatefulSet?

You cannot scale down a StatefulSet when any of the stateful Pods it manages is unhealthy. Scaling down only takes place after those stateful Pods become running and ready. If spec. replicas > 1, Kubernetes cannot determine the reason for an unhealthy Pod.

Article first time published on

How do I cancel StatefulSet?

Deleting a StatefulSet You can delete a StatefulSet in the same way you delete other resources in Kubernetes: use the kubectl delete command, and specify the StatefulSet either by file or by name. You may need to delete the associated headless service separately after the StatefulSet itself is deleted.

How do you expose StatefulSet in Kubernetes?

StatefulSet Pods have the label: which contains their generated name ( <StatefulSet Name>-<Ordinal> ). You can create individual Services for each instance that use that label as their selector to expose the individual instances of the StatefulSet.

Can I run database on Kubernetes?

A database on Kubernetes is deployed with a persistent volume, which is used to persist data as long as your cluster is running. This means it withstands the destruction of the pod, and any new pod that’s created will start using the volume again.

Can I run MySQL on Kubernetes?

Deploy MySQL You can run a stateful application by creating a Kubernetes Deployment and connecting it to an existing PersistentVolume using a PersistentVolumeClaim. … The file defines a volume mount for /var/lib/mysql, and then creates a PersistentVolumeClaim that looks for a 20G volume.

What is the difference between ReplicaSet and Deployment?

A ReplicaSet ensures that a specified number of pod replicas are running at any given time. However, a Deployment is a higher-level concept that manages ReplicaSets and provides declarative updates to Pods along with a lot of other useful features.

What is ingress k8s?

In Kubernetes, an Ingress is an object that allows access to your Kubernetes services from outside the Kubernetes cluster. You configure access by creating a collection of rules that define which inbound connections reach which services.

How can I make a headless service to bring together the pods in a StatefulSet?

How can I make a headless Service to bring together the Pods in a StatefulSet? [] By specifying Headless for the service type in the Service definition.. You just studied 2 terms!

What is a headless service?

A headless service is a service with a service IP but instead of load-balancing it will return the IPs of our associated Pods. This allows us to interact directly with the Pods instead of a proxy. It’s as simple as specifying None for .

Do Daemonsets ignore taints?

Even though most workloads won‘t be scheduled on the master because of its NoSchedule and NoExectue taints, a canal pod will be run there because the daemonset tolerates those taints specifically.

What is ConfigMap in Kubernetes?

A ConfigMap is an API object that lets you store configuration for other objects to use. Unlike most Kubernetes objects that have a spec , a ConfigMap has data and binaryData fields. These fields accept key-value pairs as their values. Both the data field and the binaryData are optional.

Is Kube proxy a DaemonSet?

Since Kube-proxy runs as a daemonset, you have to ensure that the sum of up metrics is equal to the number of working nodes.

Why do we need pod?

Pods are designed to support multiple cooperating processes (as containers) that form a cohesive unit of service. The containers in a Pod are automatically co-located and co-scheduled on the same physical or virtual machine in the cluster.

Why pod is smallest unit in Kubernetes?

A Kubernetes pod is a collection of one or more Linux® containers, and is the smallest unit of a Kubernetes application. Any given pod can be composed of multiple, tightly coupled containers (an advanced use case) or just a single container (a more common use case).

What is difference between container and pod?

“A container runs logically in a pod (though it also uses a container runtime); A group of pods, related or unrelated, run on a cluster. A pod is a unit of replication on a cluster; A cluster can contain many pods, related or unrelated [and] grouped under the tight logical borders called namespaces.”

What is Kubernetes namespace?

Namespaces are a way to organize clusters into virtual sub-clusters — they can be helpful when different teams or projects share a Kubernetes cluster.

What is PVC Devops?

Persistent Volume Claims (PVC) PVC is binding between a Pod and PV. Pod request the Volume through the PVC. PVC is the request to provision persistent storage with a specific type and configuration.

What can you deploy on Kubernetes?

The Pod is the smallest deployable unit in Kubernetes. Usually, you deploy Pods as a set of replicas that can be scaled and distributed together across your cluster. One way to deploy a set of replicas is through a Kubernetes Deployment.

How do you scale replicas in Kubernetes?

  1. Edit the controllers configuration by using kubectl edit rs ReplicaSet_name and change the replicas count up or down as you desire.
  2. Use kubectl directly. For example, kubectl scale –replicas=2 rs/web .

How do you stop a pod?

Destroy Pod The action of deleting the pod is simple. To delete the pod you have created, just run kubectl delete pod nginx . Be sure to confirm the name of the pod you want to delete before pressing Enter. If you have completed the task of deleting the pod successfully, pod nginx deleted will appear in the terminal.

How does scaling work in Kubernetes?

Overview. When you deploy an application in GKE, you define how many replicas of the application you’d like to run. When you scale an application, you increase or decrease the number of replicas. Each replica of your application represents a Kubernetes Pod that encapsulates your application’s container(s).

What is Openshift StatefulSet?

StatefulSet is the workload API object used to manage stateful applications. Manages the deployment and scaling of a set of Pods, and provides guarantees about the ordering and uniqueness of these Pods. Like a Deployment, a StatefulSet manages Pods that are based on an identical container spec.