Creating StatefulSet

StatefulSet is a Kubernetes controller designed to manage stateful applications by orchestrating Pod instances with stable network identities and persistent storage. Within a single application architecture, you may deploy multiple StatefulSets as discrete components to deliver specialized services while maintaining ordered deployment, scaling, and rolling updates.

Prerequisites

Obtain the image address. The source of the images can be from the image repository integrated by the platform administrator through the toolchain or from third-party platforms' image repositories.

  • For the former, the Administrator typically assigns the image repository to your project, and you can use the images within it. If the required image repository is not found, please contact the Administrator for allocation.

  • If it is a third-party platform's image repository, ensure that images can be pulled directly from it in the current cluster.

Procedure

  1. Container Platform, navigate to Workloads > StatefulSets in the left sidebar.

  2. Click Create StatefulSet.

  3. Select or Input an image, and click Confirm.

    Note: You can filter images by selecting only when using images from the integrated image repository of this platform. For example, the integrated project name such as containers (docker-registry-projectname) includes the project name projectname from this platform and the project name containers from the image repository.

Configure Basic info

In the Basic Info section, configure declarative parameters for Deployment workloads:

ParametersDescription
ReplicasDefines the desired number of Pod replicas in the Deployment (default: 1). Adjust based on workload requirements. Please set this according to the actual business request volume.
Update StrategyControls phased updates in StatefulSet rolling updates:
1. Partition Value:
  • Specifies the ordinal threshold for Pod updates.
2. Behavior:
  • Pods with ordinal ≥ partition value will update immediately.
  • Pods with ordinal < partition value retain previous template.
3. Invalid Case:
  • If partition > replica count, treated as 0
Example:
  • Replicas=5 (Pods: web-0 ~ web-4)
  • Partition=3 → Updates web-3 & web-4 only.
Volume Claim TemplatesvolumeClaimTemplates is a critical feature of StatefulSets that enables dynamic per-Pod persistent storage provisioning. Each Pod replica in a StatefulSet automatically gets its own dedicated PersistentVolumeClaim (PVC) based on predefined templates.
1. Dynamic PVC Creation: Automatically creates unique PVCs for each Pod:
  • Naming pattern: <statefulset-name>-<claim-template-name>-<pod-ordinal>
  • Example: web-data-0, web-data-1
2. Access Modes: Supports all Kubernetes access modes:
  • ReadWriteOnce (RWO): Single-node read/write
  • ReadOnlyMany (ROX): Multi-node read-only
  • ReadWriteMany (RWX): Multi-node read/write
3. Storage Class: Specify storage backend via storageClassName:
  • Uses cluster's default StorageClass if unspecified
  • Supports cloud/on-prem storage types (SSD, HDD, etc.)
Capacity: Configure capacity through resources.requests.storage:
  • Example: 100Gi
  • Supports dynamic volume expansion (if enabled)

Configure Pod

In the Pod section, please refer to Creating Deployment - Configure Pod

Configure Containers

In the Container section, please refer to Creating Deployment - Configure Containers

Create

Click Create.