StatefulSets
A StatefulSet is a workload for managing stateful applications, such as MySQL, that save data or state during runtime. You can create a StatefulSet using a YAML file. After a StatefulSet is created, you can monitor, delete, or perform other operations on it.
StatefulSet is a native Kubernetes resource. For more information, see the official Kubernetes documentation.
Create a StatefulSet
This section describes how to create a StatefulSet using a YAML file.
Procedure
Log on to the SOFASTACK console.
In the navigation pane on the left, click Container Application Service > Workloads > StatefulSets.
On the StatefulSets page, click Create from YAML.
Enter the YAML content in the text box and click Submit.
The following is a sample:
kind: StatefulSet metadata: name: stexample namespace: yournamespace # Change this to your current namespace name spec: replicas: 1 selector: matchLabels: k8s-app: stexample template: metadata: labels: k8s-app: stexample spec: containers: - name: nginx image: reg-cnsh.cloud.alipay.com/library/nginx:latest
After the StatefulSet is created, its status is Running.
Update a StatefulSet
This section describes how to update a StatefulSet by modifying its YAML file.
Prerequisites
The YAML has been created.
Procedure
Log on to the SOFASTACK console.
In the navigation pane on the left, click Container Application Service > Workloads > StatefulSets.
On the StatefulSets page, find the StatefulSet that you want to update and click View/Edit YAML in the Actions column.
Modify the configuration in the YAML editor and click Update.
After the update is complete, the system automatically deploys the StatefulSet based on the new YAML file.
Delete a StatefulSet
This section describes how to delete a StatefulSet.
Prerequisites
The YAML file is created.
Procedure
Log on to the SOFASTACK console.
In the navigation pane on the left, click Container Application Service > Workloads > StatefulSets.
On the StatefulSets page, find the StatefulSet that you want to delete and click Delete in the Actions column. In the dialog box that appears, click OK.
Monitor a StatefulSet
This section describes how to monitor a StatefulSet.
Prerequisites
The YAML configuration is created.
Procedure
Log on to the SOFASTACK console.
In the navigation pane on the left, click Container Application Service > Workloads > StatefulSets.
On the StatefulSets page, find the desired StatefulSet and click Monitoring in the Actions column. You are redirected to the CloudMonitor console, where you can view the monitoring metrics for the StatefulSet.
For more information about the operations in the CloudMonitor console, see View application groups.