An increasing number of microservices applications use multiple programming languages such as Python, Go, and Node.js. Enterprise Distributed Application Service (EDAS) allows you to deploy multi-language microservices applications by using a service mesh. EDAS provides service governance capabilities and the following features for microservices applications: application management, service discovery, tracing analysis, load balancing, and application monitoring. This topic provides an example on how to use images to deploy multi-language microservices applications in EDAS.

Prerequisites

EDAS and Container Service for Kubernetes (ACK) are activated for your Alibaba Cloud account. For more information, see the following topics:

Background information

Applications have evolved from the original monolithic architecture to the current microservices architecture. The microservices architecture facilitates application development. However, the microservices architecture increases complexity in service deployment and O&M. Microservices can be developed in all programming languages. After you deploy a multi-language microservice, you can use the SDKs for different programming languages or service meshes to provide features for the microservice, such as tracing analysis, service discovery, and load balancing. In tracing analysis, service discovery, and load balancing, the SDKs for different programming languages are intrusive to applications, whereas service meshes are considered to be non-intrusive to applications. Therefore, EDAS uses service meshes to support multi-language microservices.

A service mesh is a dedicated infrastructure layer that implements service-to-service communication. A service mesh provides a stable and reliable method to deliver requests. If you use a service mesh, you do not need to be concerned about the complex topology of services that compose a modern, cloud-native application. In most cases, a service mesh is implemented as an array of lightweight network proxies that are deployed in combination with application code. This way, you do not need to be concerned about the status of the application.

Scenario

BookInfo is an application that displays the detailed information about a book. The application functions as a filter for an online bookstore. The application displays the description of a book, details such as the International Standard Book Number (ISBN) and the number of pages, and reviews on the book.

BookInfo is a heterogeneous application that consists of several microservices applications. These microservices applications are developed in different programming languages. These microservices applications form a classic service mesh, which consists of multiple services that are written in different programming languages. Among these services, the Reviews service has multiple versions.

Figure 1. Architecture for multi-language services
Microservices architecture based on EDAS

The BookInfo application consists of the following four independent services:

  • Productpage: a Python service that calls the Details and Reviews services to generate a page. The Productpage service provides the logon and logoff features.
  • Details: a Ruby service that provides book information.
  • Reviews: a Java service that provides book reviews and calls the Ratings service. The Reviews service has the following three versions:
    • Version 1, which does not call the Ratings service.
    • Version 2, which calls the Ratings service and rates a book with one to five black stars.
    • Version 3, which calls the Ratings service and rates a book with one to five red stars.
  • Ratings: a Node.js service that provides ratings generated based on book reviews.

Procedure

Before you can deploy applications in a Kubernetes cluster, you must create a cluster in the ACK console and import the cluster to EDAS in the EDAS console. Then, you can use a custom image to deploy an application in the cluster.

Note This topic describes how to deploy an application in an ACK cluster. The procedure for deploying an application in a serverless Kubernetes cluster is similar.
Procedure for deploying an 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 EDAS in 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 of the microservices namespace that you want to manage. From the Microservice Namespace drop-down list, select the microservices namespace to which you want to import the ACK cluster. Then, click Synchronize Container Service Kubernetes Cluster.
  4. Find the ACK cluster that you want to import and click Import in the Actions column.
  5. In the Import Kubernetes Cluster dialog box, select a microservices namespace from the Microservice Namespaces drop-down list, turn on Service Mesh, and then click Import.
    Note
    • If you have not created a microservices namespace, the default microservices namespace is selected.
    • If you do not enable the integration with ASM when you import the ACK cluster, you can enable the integration in the Service Mesh column of the Container Service Kubernetes Clusters page after the cluster is imported.
    • By default, two internal-facing Server Load Balancer (SLB) instances are created when you enable the integration with ASM. The specifications of the two SLB instances are slb.s1.small. The ports of the two SLB instances, port 6443 and port 15011, are exposed. For more information, see the "Background information" section of the Create an ASM instance topic.

      You are charged for the two SLB instances that are automatically created.

    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: Enable the integration with Tracing Analysis

The Istio service mesh allows you to use Tracing Analysis to monitor multi-language applications in the EDAS console. The Istio proxy can automatically send span information. However, applications must carry HTTP headers so that the span information can be associated with an individual trace.

Applications must carry the following HTTP headers and pass them from inbound requests to outbound requests:
  • x-request-id
  • x-b3-traceid
  • x-b3-spanid
  • x-b3-parentspanid
  • x-b3-sampled
  • x-b3-flags
  • x-ot-span-context

In this example, only the HTTP headers that are carried in the applications of specified services in the sample multi-language application are described.

The following HTTP headers are carried in the Python application of the Productpage service:
def getForwardHeaders(request):
    headers = {}

    # x-b3-*** headers can be populated using the opentracing span
    span = get_current_span()
    carrier = {}
    tracer.inject(
        span_context=span.context,
        format=Format.HTTP_HEADERS,
        carrier=carrier)

    headers.update(carrier)

    # ...

    incoming_headers = ['x-request-id']

    # ...

    for ihdr in incoming_headers:
        val = request.headers.get(ihdr)
        if val is not None:
            headers[ihdr] = val

    return headers
The following HTTP headers are carried in the Java application of the Reviews service:
@GET
@Path("/reviews/{productId}")
public Response bookReviewsById(@PathParam("productId") int productId,
                            @HeaderParam("end-user") String user,
                            @HeaderParam("x-request-id") String xreq,
                            @HeaderParam("x-b3-traceid") String xtraceid,
                            @HeaderParam("x-b3-spanid") String xspanid,
                            @HeaderParam("x-b3-parentspanid") String xparentspanid,
                            @HeaderParam("x-b3-sampled") String xsampled,
                            @HeaderParam("x-b3-flags") String xflags,
                            @HeaderParam("x-ot-span-context") String xotspan) {

  if (ratings_enabled) {
    JsonObject ratingsResponse = getRatings(Integer.toString(productId), user, xreq, xtraceid, xspanid, xparentspanid, xsampled, xflags, xotspan);

Step 4: Deploy a multi-language application in the Kubernetes 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.
    Section Description
    Cluster Type The type of the cluster in which you want to deploy the application. Select Kubernetes Clusters.
    Application Runtime Environment The runtime environment of the application. Set the Hosted Applications parameter to Node.js, C++, Go, and Other Languages. By default, the Select Application parameter is set to Custom. A value of Custom indicates that the application can be deployed by using a custom image.
  4. In the Configurations step, configure the environment information, basic information, and image settings for the application, and click Next.
    Parameter Description
    Microservice Namespace The microservices namespace of the Kubernetes cluster. If you have not created a microservices namespace or do not select a microservices 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.

    To monitor and manage multi-language applications, you must click Enable to enable the integration with ASM.

    K8s Namespace The Kubernetes namespace of the cluster. Internal system objects are allocated to different Kubernetes 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, default is selected.

    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.
    Version The version of the application. You can click Generate Version Number on the right side of the page to generate a version number. You can also specify a version number by following the on-screen instructions.
    Image Type The type of the image that is used to deploy the application. In this example, Demo Image is selected. Then, select the edas-demo-image/provider image and specify an image version.
    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 on the CPU and memory quotas.
  5. In the Advanced Settings step, set the parameters as required and click Create Application.
    1. Configure the service mesh.
      Parameter Description
      Protocol The protocol to be used. Select a supported protocol from the drop-down list.
      Service Name The name of the microservice that is provided by the application. The service name must be the same as that provided in the application code. This ensures that the microservice can be registered and called.
      Service Port The port of the microservice that is provided by the application. The service port must be the same as that provided in the application code. This ensures that the microservice can be registered and called.
    2. Optional: Configure the following advanced settings:
  6. After the settings are configured, click Create Application. In the Creation Completed step, click Create Application.
    You may need to wait several minutes before the application is deployed. During this process, you can click View Details in the upper part of the page to go to the Change List page. On the Change List page, you can view the deployment progress and related logs. 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.
  7. Repeat the preceding steps to deploy the client-side application.
    Note In Step 4, select edas-demo-image/consumer for the Image Type parameter to complete the deployment.

Verify the result

After the application is deployed, access the main service. The application page displays the description of a book, details such as the ISBN and the number of pages, and reviews on the book. You can also perform logon and logoff operations.

  1. In the Access configuration section of the Application Overview page, click the plus icon next to SLB (Public Network).
  2. In the SLB (Public Network) dialog box, set the parameters to configure an SLB instance and a listener, and click OK.
    1. Select Create SLB from the Select SLB drop-down list.
      If you have created an SLB instance, you can select the SLB instance from the list.
    2. Select a protocol and click Add Listener on the right of the protocol. Then, set the SLB port to 80, and the container port to 18082.
      Note If you select HTTPS, you must also set the SSL Certificate parameter.
      An Internet-facing SLB instance takes about 30 seconds to be added or created. On the right side of SLB (Public Network) in the Access configuration section, the endpoint of the Internet-facing SLB instance appears after the instance is added or created. The format of the endpoint is SLB instance IP address:Port number.
  3. Copy and paste the endpoint of the Internet-facing SLB instance to your browser and press the ENTER key to open the homepage of the sample application (online bookstore).
    Access the client-side application
  4. On the homepage of the client-side application, click Normal user or Test user.
  5. In the upper part of the page, click Sign in. Enter values in the User Name and Password fields and click Sign in to log on to the sample application.
    In this example, both the User Name and Password parameters are set to admin. Sign in
    In the sample application, you can view the details of a book and reviews on the book. Book details and reviews

Implement application monitoring

After you deploy the sample application, you can collect key metrics to monitor the health status of the application. The metrics include general metrics, service metrics, and system information such as the CPU and memory usage. The general metrics include the total number of requests and the average response time. The service metrics are related to the services provided by the application and the services on which the application depends.

  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. On the Applications page, click the name of the desired application.
  3. View the metrics that indicate the health status of the application.
    1. In the left-side navigation pane, click Application Overview.
    2. On the right side of the Application Overview page, click the Overall Analysis tab.
      On the Overall Analysis tab, you can view the general metrics of the application, such as the total number of requests and the average response time. You can also view the metrics about the services provided by the application and the services on which the application depends. For more information, see Overall tab.
    3. On the right side of the Application Overview page, click the Topology Graph tab.
      On the Topology Graph tab, you can view the parent components and child components of the application, and the relationships among the components. You can also view metrics such as the number of requests, response time, and error rate. For more information, see Topology tab.
  4. Check the system resource usage of the application.
    1. In the left-side navigation pane, choose Monitor > Prometheus.
    2. On the Prometheus page, set the namespace and Pod parameters in the upper-left corner and select the required time range in the upper-right corner.
      On this page, you can view the system information about the application, such as the IP address, status, containers, CPU utilization, and memory usage of the selected pod. For more information, see View Grafana dashboards. Prometheus monitoring - System information

FAQ

How do I view the error logs that track application changes?

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

DingTalk group for microservice-oriented applications developed by using multiple programming languages in EDAS

If you have questions or suggestions when you deploy microservice-oriented applications by using multiple programming languages in EDAS, submit a ticket. To give feedback, you can also join the DingTalk group by scanning the following QR code or searching for the DingTalk group ID 23307994.