StatefulSets

更新时间:
复制 MD 格式

StatefulSets are workloads designed for stateful applications, such as MySQL, that need to preserve their state during runtime. You can use the LHC console to manage StatefulSets, including creating, updating, and deleting them.

Note

StatefulSets are a native Kubernetes concept. For more information, see the official Kubernetes documentation.

Create a StatefulSet

  1. Log on to the LHC console. In the navigation pane on the left, click Cluster Management > Cluster > Details. The cluster list page opens.

  2. Click the name of the destination cluster. On the Cluster Details page, click the Workloads tab.

  3. In the left-side menu, choose StatefulSets, and then click Create StatefulSet.

  4. In the dialog box that appears, enter the YAML content and click Submit.

    The following is a sample YAML configuration:

    kind: StatefulSet
    metadata:
      name: statefulset-example
      labels:
        k8s-app: statefulset-example
      namespace: default
    spec:
      replicas: 1
      selector:
        matchLabels:
          k8s-app: statefulset-example
      template:
        metadata:
          labels:
            k8s-app: statefulset-example
        spec:
          containers:
            - name: nginx
              image: 'registry-vpc.cn-hangzhou.aliyuncs.com/sofa-samples/nginx:latest'

Result

After the StatefulSet is created, the StatefulSet named statefulset-examplee appears in the list.

Related operations

  • To view the details of a StatefulSet, click its name on the list page. The details page displays the basic information, pod list, events, and YAML configuration of the StatefulSet.

  • To search for a StatefulSet, enter a keyword from the StatefulSet name in the search box in the upper-right corner of the list page.

  • To update a StatefulSet, click View/Edit in the Actions column on the list page. In the Edit StatefulSet dialog box, edit the YAML configuration and then click Submit.

  • To delete a StatefulSet, click the more icon in the Actions column on the list page and choose Delete. In the dialog box that appears, click OK.