Enterprise Distributed Application Service (EDAS) fully integrates Alibaba Cloud Container Service for Kubernetes (ACK) on the basis of cloud native Kubernetes, and supports full lifecycle management of Kubernetes containerized applications. A Container Service Kubernetes cluster integrates capabilities of Alibaba Cloud in virtual machines, storage, networking, and security, and provides an excellent runtime environment for Kubernetes containerized applications. This topic describes how to use demo JAR packages to deploy applications in a Container Service Kubernetes cluster.

Background

To deploy applications in a Container Service Kubernetes cluster, you must create a Container Service Kubernetes cluster in the ACK console, import the cluster to the EDAS console, and then use deployment packages or images to deploy applications in the imported cluster.

Prerequisites

Step 1: Create a Container Service Kubernetes cluster

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

Step 2: Import the Container Service Kubernetes cluster to the EDAS console

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, choose Resource Management > Cluster.
  3. On the Cluster page, click Alibaba Cloud Container Service for Kubernetes Cluster. In the cluster list, find the target Container Service Kubernetes cluster and click Import in the Actions column. In the Import Kubernetes Cluster dialog box, set Namespace and click Import.
    • To import the created Container Service Kubernetes cluster, click Import in the Actions column.
    • To delete the imported Container Service Kubernetes cluster, click Cancel in the Actions column.
    • If the import fails, click Retry in the Actions column.
    • To view the import log, click Log in the Actions column.
    When the Cluster Status of the Container Service Kubernetes cluster is Running and Import Status is Imported, the Container Service Kubernetes cluster has been imported into EDAS.

Step 3: Deploy an application in the Container Service Kubernetes cluster

Note The deployment procedure by using a WAR package is the same as the deployment procedure by using a JAR package. This topic uses JAR as an example to describe how to deploy an application.
  1. Log on to the EDAS console.
  2. In the left-side navigation pane, choose Application Management > Applications. On the Applications page, click Create Application.
  3. On the Application Information tab, set Cluster Type and Application Runtime Environment, and click Next.
    Parameter Description
    Cluster Type Select Kubernetes Cluster.
    Application Runtime Environment In this topic, select Java as an example.
    • Custom: Select this option if you want to deploy an application in a Kubernetes cluster by using a custom image.
    • Java: Select this option if you want to deploy a Dubbo or Spring Cloud application in a Kubernetes cluster by using a universal JAR package. You can change the Java environment after you select this mode.
    • Tomcat: Select this option if you want to deploy a Dubbo or Spring Cloud application in a Kubernetes cluster by using a universal WAR package. You can change the Java environment and the container version after you select this mode.
    • EDAS-Container (HSF): Select this option if you want to deploy a High-Speed Service Framework (HSF) application by using a WAR or FatJar package. You can change the Java environment, Pandora version, and Ali-Tomcat version after you select this mode.
  4. On the Application Configuration tab, configure the environment information, basic information, deployment method, and resource parameters for the application, and click Next.
    Parameter Description
    Namespace Select the namespace that you created. If you have not created a namespace or do not select a namespace, it is set to default.
    Cluster Select the imported Container Service Kubernetes cluster from the drop-down list.
    K8s Namespace Internal system objects are allocated to different namespaces to form logically isolated projects, groups, or user groups. In this way, different groups can share the resources of the whole cluster when they are managed separately. Select default.
    Application Name Enter the application name. The name must start with a letter and can contain digits, letters, and hyphens (-). The name must be 1 to 36 characters in length.
    Application Description Enter the description of the application. The description can be up to 128 characters in length.
    Source of Deployment Package
    • Customer Program
      Set File Uploading Method.
      • Upload JAR Package: Select and upload the downloaded JAR package.
      • JAR Package Location: Enter the address of the 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 as needed.

    Version Enter a version number. You can specify a version number or click Use Timestamp as Version Number.
    Time Zone Set the time zone of the application.
    Total Pods Set the number of pods to be deployed for this application.
    Single Pod Resource Quota Enter the CPU cores and memory for an individual pod. To set the quota, enter a number. The default value 0 indicates no quota.
  5. (Optional) Configure information on the Advanced Application Setting tab.
    1. Configure the scheduling rules of the application.
      Parameter Description
      Default Scheduling Instances are scheduled based on the status of cluster resources by default and may be all deployed to a single zone, and therefore the availability of the instances is medium.
      Deploy in Multiple Zones As Possible Instances are scattered and deployed to as many zones as possible according to anti-affinity rules, and therefore the availability of the instances is high.
    2. Set the startup command and parameters.
      Note If you do not know the CMD and ENTRYPOINT content of the original Dockerfile image, do not modify the custom startup command and parameters. Otherwise, you cannot create applications due to an incorrect custom command.
      Parameter Description
      Startup Command Enter the startup command. To run the CMD ["/usr/sbin/sshd","-D"] command, enter /usr/sbin/sshd –D in the field.
      Startup Parameters Write one parameter per line. For example, args:["-c"; "while sleep 2"; "do echo date"; "done"] contains four parameters. You need to click Add to enter these parameters in four lines.
    3. Set environment variables.
      When you create the application, inject the environment variables you have entered to the container that will be generated. This saves you from repeatedly adding common environment variables.
      • If you need to set parameters such as the JVM heap memory, JVM property parameters, and javaagent, you can add the relevant parameters when you set environment variables:
        • Variable Name: CATALINA_OPTS.
        • Variable Value: [Parameters to be added] $(EDAS_CATALINA_OPTS).
      • If you are using a MySQL image, see the following environment variables:
        • MYSQL_ROOT_PASSWORD (required): allows you to set a MySQL root password.
        • MYSQL_USER and MYSQL_PASSWORD (optional): allows you to add an account in addition to the root account and set a password.
        • MYSQL_DATABASE (optional): allows you to set the database that you want to create when the container is generated.
      • If you are using another type of image, set the environment variables as needed.
    4. Set persistent storage.

      In Container Service Kubernetes clusters of Alibaba Cloud, the physical storage of a native volume object is not persistent. That is, the volume object is a temporary storage object and has the same lifecycle as Kubernetes pods. You can use the Apsara File Storage NAS (NAS), persistent storage service provided by Alibaba Cloud to store instance data persistently. When an instance is upgraded or migrated, the instance data is retained.

      Note Before you configure persistent storage, ensure that you have activated NAS for your Alibaba Cloud account that uses the EDAS service. When you use NAS, make sure that your current account has a sufficient balance or the billing method is pay-as-you-go. For more information about the billing rules of NAS, see Billing Methods.
      Parameter Description
      Storage Type The default value is NAS, which cannot be changed.
      Storage Service Type Currently, only the Solid State Drive (SSD) performance type is supported, which cannot be changed.
      Select NAS
      • Buy New NAS: Select an NAS mount directory and a local mount directory. A single region supports up to 10 NAS instances. When this number in a single region exceeds 10, your attempt to create more NAS instances fails. If you need to create more NAS instances, submit a ticket.
      • Use Existing NAS: Select an existing NAS instance. You can create up to two mount points. Only compliant NAS instances appear in the drop-down list.
      Mount Directory Set the mount directory command.
    5. Set local storage.

      You can map part of the file system of the host to the container as needed. Before you use this function, read hostpath and consider the rationality of the solution.

      File Type Value Description
      Default Null string Indicates that the file is directly mounted without the file type check.
      (Create) File Directory DirectoryOrCreate The file directory. If no file directory exists, a new directory is created.
      File Directory Directory The file directory. If the file directory does not exist, container startup fails.
      (Create) File FileOrCreate The file. If the file does not exist, a new file is created.
      File File The file. If the file does not exist, container startup fails.
      Socket Socket The standard UNIX Socket file. If the file does not exist, container startup fails.
      CharDevice CharDevice The character device file. If the file does not exist, container startup fails.
      BlockDevice BlockDevice The block storage device file. If the file does not exist, container startup fails.
      Note You do not need to pay attention to the Value column in this step. However, the Value column may be used by API operations after the application is created.
    6. Configure application lifecycle management.
      Parameter Description
      PostStart Configuration A container hook, which is triggered immediately after a container is created to notify the container of its creation. The hook does not pass any parameters to the corresponding hook handler. If the corresponding hook handler fails to run, the container is killed and the restart policy of the container is used to determine whether to restart the container. For more information, see Container Lifecycle Hooks.
      PreStop Configuration A container hook, which is triggered before a container is deleted. The corresponding hook handler must be executed before the request to delete the container is sent to the Docker daemon. The Docker daemon sends an SGTERN semaphore to itself to delete the container, regardless of the execution result of the corresponding hook handler. For more information, see Container Lifecycle Hooks.
      Liveness Configuration A container status probe, which monitors the health status of applications. If an application is unhealthy, its corresponding container is deleted and recreated. For more information, see Pod Lifecycle.
      Configure Readiness A container status probe, which monitors whether applications have started and are running properly. If an application is not running, the container status is updated. For more information, see Pod Lifecycle.
    7. Configure log collection.

      You can activate Log Service (SLS). Then, EDAS can store business logs and container standard output (stdout) and standard error (stderr) logs to SLS. In this way, you can view logs without limits on the number of lines and perform automatic aggregation and analysis on these logs. SLS is billed on a pay-as-you-go basis.

      Parameter Description
      Logstore Name Enter the name of the Logstore. If the Logstore does not exist, a new Logstore is created.
      Collection Log Type You can select File Logs (Log Path in the Container) or Standard Output Logs of the Container.
      Collection Path Enter the log path in the container.
  6. Click Create Application.
    It takes several minutes to create an application. You can track the creation progress based on the change record . After the application is created, the Application Overview page appears. You can check the running status of the instance pod. If the pod is running, the application is published. You can click the running status of the pod to view the advanced configuration information, such as Deployment, Pod, and Startup Command.