This topic describes how to manage the lifecycle of a Kubernetes-native StatefulSet, for example, how to create, configure, and delete a StatefulSet.
Create a StatefulSet
To create a StatefulSet, perform the following steps:
- Log in to the KCE console.
- In the left navigation pane, click ServerlessCluster. The cluster management page appears.
- Click the ID of the cluster in which you want to create a StatefulSet. The cluster details page appears.
- In the left navigation pane, choose Workload > StatefulSet. The StatefulSet list page appears.
- Click Create in the upper-left corner. On the Create StatefulSet page, complete the required configuration and click Create.
The configuration items are described as follows:
Set Basic Information
- Name: the name of the StatefulSet, which can be up to 63 characters in length, and can contain lowercase letters, digits, and hyphens (-). The name must start with a lowercase letter and end with a lowercase letter or a digit.
- Namespace: the namespace of the cluster to which the StatefulSet belongs.
- Description: the description about the StatefulSet. Enter a custom description.
- Type: the type of the volume. EmptyDir, Kingsoft Cloud Elastic Block Storage, Existing PVC, ConfigMap, and Secret are available.
- Volume Name: the name of the volume.
- Resource Name: the name of the storage resource.
- Other Information: the mount information about the Secret or ConfigMap volume.
If you select Kingsoft Cloud Elastic Block Storage, the volume name is the ID of the EBS instance and cannot be modified.
Name: the name of the container, which can be up to 63 characters in length, and can contain lowercase letters, digits, and hyphens (-). The name must start with a lowercase letter and end with a lowercase letter or a digit.
Image: the image of the container. You can enter the address of an image repository, or click Select Image to select an image from an image repository.
Tag: the tag of the image.
Resources: the limits on the CPU and memory resources for the container.
VolumeMount: the mount path and read/write privilege of the volume. This item is available only when a volume is added.
- Environment Variable: the environment variable of the container. You can manually add environment variables to set parameters.
Image Access Credential
This item is available when you pull images from a private image repository. This item corresponds to imagePullSecret in the YAML file.
- ksyunregistrykey is available by default. It matches the private images in the Kingsoft Cloud image repository.
- To use images from a third-party private image repository, create an access credential for the image repository by performing the following operations: Click Add Image Access Credential, select Use New Access Credential, and then click Configure Access Credential. In the dialog box that appears, set the name of the new access credential, enter the repository domain, set the user name and password for accessing the image repository, and then click Create Secret.
- Associated Service: If Enabled is cleared, no entry to the container is provided for frontend service access requests.
- Public Access(LoadBalancer): This option allows services to be exposed to the Internet through SLB so that they can be accessed over the Internet.
- Via VPC(LoadBalancer): This option allows services to be exposed to the VPC where the Kubernetes cluster resides through SLB so that they can be accessed by other Kubernetes clusters or KEC instances in the VPC.
After the configuration is completed, click Create and check the status of the StatefulSet on the StatefulSet list page.
Update a StatefulSet
On the StatefulSet list page, click Update for a StatefulSet. On the Update StatefulSet page, update the StatefulSet configuration based on your business requirements.
- Rolling Update: This option updates the pods one by one without interrupting your business. You can specify the parameters for a rolling update.
- OnDelete: This option triggers creation of a pod after you manually delete a pod. This option is selected by default.
Pod Management Policy:
- OrderedReady: This option starts or stops all pods in sequence. It allows you to start or stop a pod only after the previous pod enters the Running, Ready, or Stopped state. This option is selected by default.
- Parallel: This option starts or stops all pods in parallel. It allows you to start or stop a pod without waiting for another pod to enter the Running, Ready, or Stopped state.
Adjust the number of pods
On the StatefulSet list page, click Adjust Pod Count for a StatefulSet. In the Adjust Pod Count dialog box, manually set the number of pods.
Delete a StatefulSet
On the StatefulSet list page, move your pointer over More and click Delete for a StatefulSet. In the message that appears, click OK.