You need to enable JavaScript to run this app.
Volcengine Kubernetes Engine

Volcengine Kubernetes Engine

Copy page
Download PDF
Creating workloads
Creating StatefulSets
Copy page
Download PDF
Creating StatefulSets
A StatefulSet in Kubernetes is a workload that preserves data or state. For example, a MySQL StatefulSet saves the data that is written to it. You can create a StatefulSet in a cluster by using an image. This topic describes how to create a StatefulSet.​
Prerequisites​
A container image has been created. You can directly use an image from a third-party container registry, or upload an image to the Container Registry (CR) service. To upload an image to CR, see Pushing and pulling images.​
Use the console​
  1. Go to the StatefulSet page.​
  1. Log in to the VKE console.​
  1. In the left navigation bar, click Cluster.​
  1. On the Cluster page, click the name of the cluster for which you need to create a StatefulSet.​
  1. In the left navigation bar of the cluster management page, click Workload > StatefulSet.​
  1. On the StatefulSet page, click Create StatefulSet.​
  1. Configure the StatefulSet. For parameter details, see Workload configurations.​
  1. Click Confirm in the lower-right corner of the page.​
Use kubectl​
tip​
Before you start, make sure that the following conditions are met:​
  1. Create the YAML file of the workload. The following example is a file named statefulset-demo.yaml:​
  • ​
    apiVersion: v1​
    kind: Service​
    metadata:​
    name: statefulset-demo # The headless service name.​
    labels:​
    app: demo​
    spec:​
    ports:​
    - port: 80 # The port number for communication between pods.​
    name: web # The port name for communication between pods.​
    clusterIP: None # For a headless service, it needs to be None.​
    selector:​
    app: demo # Select pods with the key:value label.​
    ---​
    apiVersion: apps/v1​
    kind: StatefulSet​
    metadata:​
    name: statefulset-demo # The StatefulSet name.​
    namespace: default # The namespace where the StatefulSet is located.​
    spec:​
    replicas: 2 # The number of StatefulSet replicas.​
    serviceName: statefulset-demo # The headless service name.​
    selector:​
    matchLabels:​
    app: demo​
    template:​
    metadata:​
    labels:​
    app: demo​
    spec:​
    containers:​
    - name: nginx # The container name.​
    image: doc-cn-beijing.cr.volces.com/vke/nginx-demo:v1.0 # The container image address and tag.​
    ports:​
    - containerPort: 80 # The exposed port number of the container.​
    resources:​
    requests: # The container CPU and memory requests.​
    cpu: "500m" ​
    memory: "1024Mi"​
    limits: # The resource quotas, such as the CPU limit, memory limit, and number of RDMA cards.​
    cpu: "1" ​
    memory: "2Gi"​
    vke.volcengine.com/rdma: 2​
    ​
  1. Run the following command to create the workload.​
  • ​
    kubectl apply -f statefulset-demo.yaml​
    ​
Operation result​
You can click Workload > StatefulSet to check the status of the workload. You can click the button in the Actions column to manage the created StatefulSets. For more operations, see Managing workloads.​
Last updated: 2026.08.19 17:40:00