Create a stateful StatefulSet application

更新时间:
复制 MD 格式

This topic describes how to create a stateful StatefulSet application using the EDAS console.

Prerequisites

StatefulSet introduction

Similar to a Deployment, a StatefulSet maintains a specific number of pods that run normally. However, StatefulSets provide the following features to preserve the identity information of pods:

  • Ordered and fixed pod names: The pods created by a StatefulSet are sequentially named in the <StatefulSet name>-<Serial number> format. For example, if two pods are provisioned by a StatefulSet named db-app, the pods are named db-app-0 and db-app-1. When a pod is recreated, it uses the original name.

  • Stable network identifier: In most cases, you need to associate a headless Service with a StatefulSet. You can specify the name of a headless Service in the spec.serviceName parameter of the StatefulSet. The headless Service does not load balance the pods of the StatefulSet. Instead, it only provides a fixed domain name for the pod. The IP addresses of all backend pods of the headless Service are returned for DNS queries for the headless Service. After you associate a headless Service with the StatefulSet, the domain names of the pods use the <Pod name>.<Headless Service name>.<namespace>.svc.<ClusterDomain> format. Example: db-app-01.db-app.default.svc.cluster.local. If a pod is recreated, the domain name of the pod is automatically resolved to the IP address of the new pod.

  • Stable persistent storage: You can specify a persistent volume claim (PVC) template in the spec.volumeClaimTemplates parameter of the StatefulSet. The StatefulSet automatically creates a separate PVC for each pod based on the specified template. The PVCs are named in the <PVC template name>-<Pod name> format. When a pod is deleted, the related PVC is retained. When the pod is recreated, the PVC is automatically associated with the new pod, which has the original serial number.

When a pod of a StatefulSet is recreated, these features ensure that the new pod inherits the network and storage status of the original pod. This allows the new pod to recover with the data in persistent storage. For more information about StatefulSets, see StatefulSets.

Step 1: Create an ACK cluster

Log on to the ACK console and create an ACK cluster. For more information, see Create a managed Kubernetes cluster.

If you want to create an ACK Serverless cluster, set the VPC parameter to Create VPC and set the Service Discovery parameter to PrivateZone. This allows the ACK Serverless cluster to use Alibaba Cloud Service Mesh (ASM) after the cluster is imported to EDAS. If you set the VPC parameter to Select Existing VPC, check whether the cluster contains virtual private cloud (VPC) and vSwitch resources after you create the cluster. For more information, see Create an ACK Serverless cluster.

Step 2: Import an ACK cluster to the EDAS console

By default, the ack-ahas-sentinel-pilot, ack-arms-pilot, and ack-arms-prometheus components are installed when you import an ACK cluster to EDAS in the EDAS console. The ack-ahas-sentinel-pilot component is an application protection component for throttling and degradation. The ack-arms-pilot component is an Application Real-Time Monitoring Service (ARMS) component. The ack-arms-prometheus component is a Prometheus monitoring component.

  1. Log on to the EDAS console. In the left-side navigation pane, choose Resource Management > Container Service Kubernetes Clusters.

  2. In the top navigation bar, select the region in which your ACK cluster resides, and click Synchronize Container Service Kubernetes Cluster.

  3. Find the ACK cluster that is synchronized to EDAS and click Import in the Actions column.

  4. In the Precheck for Import dialog box, click Continue.

  5. In the Import Kubernetes Cluster dialog box, select the microservice namespace to which you want to import the ACK cluster from the Microservice Namespace drop-down list, turn on or off Service Mesh based on your business requirements, and then click Import.

    If the value in the Cluster Status column is Running and the value in the Import Status column is Imported for the ACK cluster, the cluster is imported to EDAS.

Step 3: Deploy an application in the ACK cluster

  1. EDAS console Log on to the . In the left-side navigation pane, choose Application Management > Applications. In the top navigation bar, select a region. In the upper part of the page, select a microservice namespace. In the upper-left corner of the Applications page, click Create Application.

  2. On the Basic Information page, set the cluster type and application runtime environment, and then click Next.

    Configuration Item

    Description

    Cluster Type

    Select Kubernetes Cluster.

    Workload Type

    Select Stateful (StatefulSet).

    Application Runtime Environment

    Hosted Applications

    This topic describes how to deploy a Java application. Therefore, select Java. To deploy a PHP or multi-language application, see Build a PHP application from source code and deploy it to an ACK cluster.

    Select Application

    This topic describes how to deploy a Java application from a JAR or WAR package. Select Java, Tomcat, or EDAS-Container (HSF) based on the application type and deployment package. To deploy an application from an image, see Deploy a Java microservice application from an image in a Kubernetes cluster.

    • Java: Supports deployment from general JAR packages. This option is suitable for Dubbo and Spring Boot applications. After you select this option, you can set the Java Environment.

    • Tomcat: Supports deployment from general WAR packages. This option is suitable for Dubbo and Spring applications. After you select this option, you can set the Java Environment and Container Version.

    • EDAS-Container (HSF): Suitable for deploying HSF applications from WAR or Fat JAR packages. After you select this option, you can set the Java Environment, Pandora Version, and Ali-Tomcat Version.

    Note

    OpenJDK 17 supports Dubbo 2.7.14, 3.0.6, and later versions. For compatibility test results, see OpenJDK 17 compatibility test data.

  3. In the Configurations step, configure the environment information, basic information, deployment method, and resource parameters for the application and click Next.

    Parameter

    Description

    Microservice Namespace

    The microservice namespace in which you want to deploy the application. Select the microservice namespace that you created. If you do not have or select a microservice namespace, this parameter is set to Default.

    If you have not created a microservice namespace or you want to create another microservice namespace, click Create Microservice Namespace to create a microservice namespace. For more information, see the "Create a namespace" section of the Manage microservice namespaces topic.

    Cluster

    The cluster in which you want to deploy the application. Select the imported ACK cluster from the Cluster drop-down list.

    If the selected Kubernetes cluster is not imported to EDAS, select This cluster is used for the first time in EDAS. If you select this check box, the cluster is imported to EDAS when an application is created. This consumes a certain amount of time. Then, check whether Alibaba Cloud Service Mesh is activated.

    Note

    You can select a cluster that does not belong to the same microservice namespace as the application.

    K8s Namespace

    The Kubernetes namespace of the application. Internal system objects are allocated to different Kubernetes namespaces to form logically isolated projects, teams, or user groups. This way, different groups can be separately managed and share the resources of the entire cluster. Valid values:

    • default: the default Kubernetes namespace. If you do not specify a Kubernetes namespace for an object, the default Kubernetes namespace is used.

    • kube-system: the Kubernetes namespace for the objects that are created by the system.

    • kube-public: the Kubernetes namespace that is automatically created by the system. This Kubernetes namespace can be read by all users, including unauthenticated users.

    In this example, select default.

    If you want to create a custom Kubernetes namespace, click Create Kubernetes Namespace. In the dialog box that appears, enter a name for the Kubernetes namespace in the K8s Namespace field. The name can contain digits, lowercase letters, and hyphens (-), and can be 1 to 63 characters in length. It must start and end with a letter or a digit.

    Application Name

    The name of the application. The name must start with a letter and can contain digits, letters, and hyphens (-). The name can be up to 36 characters in length.

    Application Description

    The description of the application. The description can be up to 128 characters in length.

    Source of Deployment Package

    Custom Program

    If you select this option, you must specify the File Uploading Method parameter. Valid values of the File Uploading Method parameter:

    • Upload JAR Package: Select and upload the JAR package that you downloaded.

    • JAR Package Address: Enter the address of your demo package.

    Official Demo

    EDAS provides the following demo types: Spring Cloud Server Application, Spring Cloud Client Application, Dubbo Server Application, and Dubbo Client Application. Select a demo type based on your business requirements.

    Container Registry Repository Type

    Note
    • The Container Registry Repository Type parameter is available only if you deploy Java, Tomcat, or EDAS-Container (HSF) applications in ACK clusters. This parameter is unavailable if you deploy applications in ASK clusters.

    • You must install the aliyun-acr-credential-helper component. For more information, see Use the aliyun-acr-credential-helper component to pull images without secrets.

    • If you want to use an image repository of Container Registry Enterprise Edition, configure access over VPCs. For more information, see Configure access over VPCs.

    • The image build task for the application runs in your cluster and consumes your resources. The default resource limit for a single image build task is 1 GB per core. For more information about how to adjust resource limits for image build tasks, see How do I adjust resource limits for image building?

    If you use a repository of Container Registry Personal Edition or Container Registry Enterprise Edition to store the created image, the image build task runs in your cluster. Build tasks are subject to the following scheduling affinity and toleration rules:

    • EDAS does not schedule build tasks to nodes that have the edas.image.build=disable label.

    • EDAS preferably schedules build tasks to nodes that have the edas.image.build=enable label. However, EDAS may also schedule build tasks to nodes that do not have the edas.image.build label.

    • Build tasks can tolerate nodes that have the key=edas.image.build, effect=NoSchedule taint.

    Note
    • If you do not want to schedule build tasks to specific nodes, add the edas.image.build=disable label to the nodes.

    • If you want to use a node as a dedicated node of a build task, you can add the edas.image.build=enable label and the key=edas.image.build, effect=NoSchedule taint to the node. This prevents pods that do not tolerate the taint from being scheduled to the node.

    Region of Container Registry

    Select the region in which your Container Registry image resides. This parameter is required only if you set the Container Registry Repository Type parameter to Container Registry Enterprise Edition.

    Container Registry

    Select your container image. This parameter is required only if you set the Container Registry Repository Type parameter to Container Registry Enterprise Edition.

    Image Repository Namespace

    Select the microservice namespace in which your image repository resides from the drop-down list. You can also click + Create Namespace to create a microservice namespace.

    Version

    The version number of your application. Specify a custom version number or click Use Timestamp as Version Number to generate a version number.

    Time Zone

    The time zone of the application.

    OpenJDK Base Image

    Note

    The OpenJDK Base Image parameter is available only if you select Custom OpenJDK from the Java Environment drop-down list in the Basic Information step.

    Configure Image

    • If you set the Alibaba Cloud Container Registry parameter to Current Account, perform the following operations:

      Configure the Region, Container Registry, Image Repository Namespace, and Image Repository Name parameters and select an image version.

    • If you set the Alibaba Cloud Container Registry parameter to Other Alibaba Cloud Accounts, perform the following operation: If your image is stored in a public repository, specify the Full Image Address parameter.

      Important

      Only JDK 7 and JDK 8 are supported. If you use a different JDK version, exceptions may be reported when you use the application monitoring feature. The EDAS server pulls the base image to build an application image. Make sure that the pull permissions on the base image are public.

    Total Pods

    The number of pods on which you want to deploy the application. The maximum number of pods is subject to the cluster performance.

    Single-pod Resource Quota

    The CPU, memory, and ephemeral storage that you want to reserve for a pod. If you want to specify a limit, enter a numeric value. The default value 0 specifies that no limit is imposed. The maximum quotas of CPU, memory, and ephemeral storage are subject to the cluster performance.

  4. (Optional) In the Advanced Settings step, configure the advanced settings.

  5. After you configure the advanced settings, click Create Application. In the Creation Completed step, click Create Application.

  6. In the Confirm Application Change Precheck dialog box, click Start Precheck.

    1. After the data in the dialog box is refreshed, confirm the precheck items and results and click Continue.

    2. (Optional) If you modify the preceding precheck items, click Check Again.

    The application requires several minutes to be deployed. During the process, you can view the change records to track the deployment progress of the application on the Change List page. After you deploy the application, go to the Application Overview page to view the running status of pods. If the pods are in the running state, the application is deployed. You can click the running status of pods to view the Deployments, pods, and advanced configurations of the application instances.

What to do next

After you deploy the application, add an Internet-facing Server Load Balancer (SLB) instance to allow access to the application over the Internet. You can also add an internal-facing SLB instance so that all the nodes in the same VPC can access the application by using this internal-facing SLB instance. For more information, see Bind CLB instances or Reuse a CLB instance.

OpenJDK 17 compatibility test data

Dubbo Version

Spring Boot Version

Nacos-Client Version

API Call

ARMS Monitoring

Service List

2.7.14

2.7.9

1.4.4

Normal

Normal

Normal

2.7.14

2.7.9

2.1.2

Normal

Normal

Normal

2.7.14

2.7.9

2.2.0

Normal

Normal

Normal

2.7.22

2.7.9

1.4.4

Normal

Normal

Normal

2.7.22

2.7.9

2.1.2

Normal

Normal

Normal

2.7.22

2.7.9

2.2.0

Normal

Normal

Normal

3.0.6

2.7.9

1.4.4

Normal

Normal

Normal

3.0.6

2.7.9

2.1.2

Normal

Normal

Normal

3.0.6

2.7.9

2.2.0

Normal

Normal

Normal

3.1.7

2.7.9

1.4.4

Normal

Normal

Normal

3.1.7

2.7.9

2.1.2

Normal

Normal

Normal

3.1.7

2.7.9

2.2.0

Normal

Normal

Normal