Enterprise Distributed Application Service (EDAS) allows you to create a PHP application from source code and deploy the application in a Container Service for Kubernetes (ACK) cluster or a serverless Kubernetes cluster. EDAS provides diverse features, such as application scaling, monitoring and alerting, load balancing, and throttling and degradation, for you to manage applications. The procedure for deploying a PHP application in an ACK cluster is similar to that for deploying a PHP application in a serverless Kubernetes cluster. This topic shows you how to build a PHP application from source code and deploy the application in an ACK cluster.


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.

To create a serverless Kubernetes cluster, set the VPC parameter to Create VPC and set the Service Discovery parameter to PrivateZone. This allows the serverless Kubernetes cluster to use Alibaba Cloud Service Mesh 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.

Create a serverless Kubernetes cluster

Step 2: Import the 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) monitoring component. The ack-arms-prometheus component is a Prometheus monitoring component.

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, choose Resource Management > Container Service Kubernetes Clusters.
  3. In the top navigation bar, select the region in which you want to import the cluster, and click Synchronize Container Service Kubernetes Cluster.
  4. In the Actions column of the ACK cluster that you want to import, click Import.
  5. In the Import Kubernetes Cluster dialog box, select the destination microservice namespace from the Microservice Namespaces drop-down list, turn on or off Service Mesh based on your business requirements, and then click Import.
    If the value of the Cluster Status parameter is Running and the value of the Import Status parameter is Imported. for the ACK cluster, the ACK cluster is imported to EDAS.

Step 3: Deploy your PHP application to the ACK cluster

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, click Applications. In the top navigation bar, select a region. In the upper part of the page, select a namespace. In the upper-left corner of the Applications page, click Create Application.
  3. In the Basic Information step, set the parameters in the Cluster Type and Application Runtime Environment sections and click Next.
    Basic information of the PHP application
    GUI element Description
    Cluster Type The type of the cluster in which you want to deploy the application. In this example, select Kubernetes Clusters.
    Application Runtime Environment The runtime environment of the application. In this example, select PHP. An image built by using EDAS provides a runtime environment for PHP 7.3 and Apache 2.4. Specific frequently used PHP plug-ins are installed in the runtime environment.
  4. In the Configurations step, configure the environment information, basic information, source code, and image settings for the application, and click Next.
    PHP application configurations
    Parameter Description
    Microservice Namespace The microservice namespace of the ACK cluster. If you have not created a microservice namespace or do not 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 is not in the microservice namespace in which you want to deploy the application.
    K8s Namespace The Kubernetes namespace of the cluster. Internal system objects are allocated to different namespaces to form logically isolated projects, groups, or user groups. This way, these projects, groups, or user groups can be separately managed but still share the resources of the entire cluster. Valid values:
    • default: the default Kubernetes namespace. If no Kubernetes namespace is specified for an object, the default Kubernetes namespace is used.
    • kube-system: the Kubernetes namespace of the objects that are created by the system.
    • kube-public: the Kubernetes namespace that is automatically created and can be read by all users, including users who are not authenticated.

    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 application 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 The way in which you want to specify the deployment package. This parameter is fixed to Source Code.
    Version The version of the application. You can specify a custom version number or click Use Timestamp as Version Number to generate a version number.
    Code Repository URL The URL of the code repository that you want to use to deploy the PHP application. Specify a URL that supports the HTTPS or Git protocol.
    Authentication Method The type of information used for authentication. If your code repository is a private repository, you must set this parameter. Valid values:
    • Username and Password: Select a secret that you have created. If no secret is available, perform the following steps to create a secret:
      1. On the right side of the Username and Password field, click Create Secret.
      2. In the Create Secret dialog box, set the Secret Name, Username, and Password parameters.
      3. In the dialog box, click Create.
    • SSH Key: Specify the SSH key provided by EDAS in the code repository. For more information, see Configure an SSH public key when you deploy an application by using source code.
    Branch or Tag The branch or tag of the code repository.
    Advanced Configuration Optional. The advanced configurations of the application. You can turn on Advanced Configuration and set the following parameters:
    • Clone Submodule: Use a Git repository as a subdirectory of another Git repository. This feature allows you to clone a repository to your project and separately commit your application code.
    • Working Directory: Specify a directory in which the files you are processing are to be stored. All the operations related to Git are performed in this directory.
    • Output Path: Specify a directory in which Git output files are to be stored.
    Total Pods The number of pods on which the application is to be deployed.
    Single-pod Resource Quota The amount of CPU and memory resources that you want to reserve for a pod. To set a limit, enter a numeric value. The default value 0 indicates that no limit is set.
  5. Optional: Configure the advanced settings for the application. Then, click Create Application.
    1. Configure environment variables.
      When you create the application, pass the environment variables that you configure to the container to be generated. This way, you do not need to repeatedly add frequently used environment variables.
      • If you want to specify parameters for the Java virtual machine (JVM) heap memory, JVM properties, and Java agent, add the parameters in this step:
        • Variable Name: CATALINA_OPTS
        • Variable Value: [Parameter to be added] $(EDAS_CATALINA_OPTS)
        Environment variable 1
      • If you are using a MySQL image, you can configure the following environment variables:
        • MYSQL_ROOT_PASSWORD: required. Allows you to set a MySQL root password.
        • MYSQL_USER and MYSQL_PASSWORD: optional. Allow you to create an account in addition to the root account and set a password.
        • MYSQL_DATABASE: optional. Allows you to specify the database that you want to create when the container is generated.
      • If you are using another type of image, configure the environment variables as needed.
    2. Configure persistent storage.

      In ACK clusters, the physical storage of a native volume object is not persistent. This means that the volume object is a temporary storage object and has the same lifecycle as a Kubernetes pod. You can use Apsara File Storage NAS (NAS) to persistently store instance data. This way, if an instance is updated or migrated, the instance data is retained.

      Note Before you configure persistent storage, make sure that you have activated NAS for the Alibaba Cloud account that you use to access EDAS. To use NAS, make sure that the Alibaba Cloud account has sufficient balance or the billing method is pay-as-you-go.
      Parameter Description
      Apsara File Storage NAS
      Note When you use the NAS service, make sure that your clusters have the FlexVolume component installed. For ASK clusters, make sure that the NAS mount directory exists. NAS is billed based on actual usage. For more information, see NAS Pricing.
      Storage Type The default value is Apsara File Storage NAS, which cannot be changed.
      Storage Service Type The default value is SSD (Performance-type), which cannot be changed.
      Select NAS
      • Buy New NAS: Select a NAS mount directory and a local mount directory. A single region supports up to 10 NAS file systems. When this number in a single region exceeds 10, your attempt to create more NAS file systems fails. To create more NAS file systems, submit a ticket.
      • Use Existing NAS: Select an existing NAS file system. You can create up to two mount targets. Only the NAS file systems that meet the requirements appear in the drop-down list.
      Mount Directory Set the NAS Mount Directory and Mount Directory in Container parameters.
      PVC Mount
      Note PVC mounts that you configure by modifying YAML files are not displayed. These configurations can be retained only during deployment. We recommend that you use EDAS to configure PVC mounts when you deploy applications.
      Select PVC Select a PVC from the drop-down list. If no PVC is available, create a PVC. For more information, see Create a PVC.
      Mount Configuration Set the Mount Directory and Mount Mode parameters.
    3. Configure application lifecycle management.
      Parameter Description
      PostStart A container hook. The hook is immediately triggered after a container is created. The hook notifies the container that the hook is created. The hook does not pass parameters to the corresponding hook handler. If the corresponding hook handler fails to be executed, the container is stopped and the restart policy of the container is used to determine whether to restart the container. For more information, see Container Lifecycle Hooks.
      PreStop A container hook. The hook is triggered before a container is deleted. The corresponding hook handler must be completely executed before the request to delete the container is sent to the Docker daemon. The Docker daemon sends an SIGTERN signal to itself to delete the container, regardless of the execution result of the corresponding hook handler. For more information, see Container Lifecycle Hooks.
      Liveness A probe that monitors your container status. The probe checks whether your applications are healthy. If an application is unhealthy, its corresponding container is deleted and re-created. For more information, see Pod Lifecycle.
      Readiness A probe that monitors your container status. The probe checks whether your applications have been started and are running as expected. If an application is not running as expected, the container status is updated. For more information, see Pod Lifecycle.
  6. After the settings are configured, click Create Application. In the Creation Completed step, click Create Application.
    The application requires several minutes to be deployed. During the process, you can view the deployment progress of the application on the Change List page. After the application is deployed, the Application Overview page appears. On this page, you can check the status of the pod. If the pod is in the Running state, the application is released. You can click the state of the pod to view the advanced settings of the application instance, such as Deployment, Pod, and Startup Command.


How do I view the error log that tracks image-based application deployment?

If you fail to use an image to deploy an application, you can view the error log on the Change List page. For more information, see View application changes.

What to do next

After the application is deployed, you can 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 SLB instances or Reuse an SLB instance.