Member-only story

K8s 2023 Interview Questions — StatefulSet

Tony
7 min readNov 3, 2023

What is a StatefulSet?

A StatefulSet in K8s is a workload controller designed for managing stateful applications, typically databases or other stateful services, where each pod needs a stable and unique network identity, and where data persistence is crucial.

StatefulSets provide a reliable way to ensure that pods are created and scaled in a specific order and maintain a consistent identity across rescheduling events.

Each pod in a StatefulSet gets a predictable, ordinal index in its hostname, allowing applications to locate and communicate with their peers easily. Unlike Deployments or ReplicaSets, StatefulSets are also tightly coupled with Persistent Volume Claims (PVCs) to provide reliable and persistent storage for the pods.

For example, consider a MySQL database cluster managed by a StatefulSet. The MySQL pods within the StatefulSet would have predictable hostnames like mysql-0, mysql-1, mysql-2, and so on, which makes it easier for applications to interact with specific database instances.

What are the Key Characteristics of StatefulSets?

  • Stable Network Identities: StatefulSets ensure that each pod has a stable and unique network identity, typically in the form of a predictable hostname.

--

--

Tony
Tony

No responses yet