StatefulSets

Updated at:

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.

Note

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

  1. Log on to the SOFASTACK console.

  2. In the navigation pane on the left, click Container Application Service > Workloads > StatefulSets.

  3. On the StatefulSets page, click Create from YAML.

  4. 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

  1. Log on to the SOFASTACK console.

  2. In the navigation pane on the left, click Container Application Service > Workloads > StatefulSets.

  3. On the StatefulSets page, find the StatefulSet that you want to update and click View/Edit YAML in the Actions column.

  4. 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

  1. Log on to the SOFASTACK console.

  2. In the navigation pane on the left, click Container Application Service > Workloads > StatefulSets.

  3. 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

  1. Log on to the SOFASTACK console.

  2. In the navigation pane on the left, click Container Application Service > Workloads > StatefulSets.

  3. 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.

Note

For more information about the operations in the CloudMonitor console, see View application groups.