Kubespec Logo kubespec.dev

apps/v1

Namespaced Resource

StatefulSet

        StatefulSet represents a set of pods with consistent identities. Identities are defined as:
  - Network: A single stable DNS and hostname.
  - Storage: As many VolumeClaims as requested.

The StatefulSet guarantees that a given network identity will always map to the same storage identity.
      

Click on Property Name to show the description, and Pink Types to expand schema.

Required properties are marked with *

Change History

Kubernetes v1.32

+2~84

Kubernetes v1.31

+7-1~43

Kubernetes v1.30

+7~21

Kubernetes v1.29

+19-2~4

Kubernetes v1.28

+4-1~25

Kubernetes v1.27

+3~21

Kubernetes v1.26

+10~3

Kubernetes v1.25

+4-4~8

Kubernetes v1.24

+2~121

Kubernetes v1.23

+13~80

Kubernetes v1.22

+12~31

Kubernetes v1.21

+13-1~12

Kubernetes v1.20

~5

Kubernetes v1.19

+6~19

Kubernetes v1.18

+1~20

Kubernetes v1.17

~14

Kubernetes v1.16

+14-6~14

Kubernetes v1.15

+7~10

Kubernetes v1.14

+7~8

Kubernetes v1.13

+1~3

Kubernetes v1.12

+4~12

Kubernetes v1.11

+6~3

Examples

There is 1 example of StatefulSet that you can use as a starting point to create your own.

apiVersion: v1
kind: Service
metadata:
  labels:
    app: nginx
    namespace: shopping-cart # StatefulSet is a namespaced resource, so we need to match it
  name: nginx
spec:
  ports:
  - port: 80
  selector:
    app: nginx
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: nginx-statefulset
  namespace: shopping-cart # StatefulSet is a namespaced resource
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  serviceName: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx:1.19.5
        name: nginx
        ports:
        - containerPort: 80
        volumeMounts:
        - mountPath: /usr/share/nginx/html
          name: web-data
  volumeClaimTemplates:
  - metadata:
      name: web-data
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 1Gi

Other useful resources