All Products
Search
Document Center

Alibaba Cloud Service Mesh:Deploy a sample app and enable ambient mode

Last Updated:Sep 21, 2026

After you add an ingress gateway to an ASM instance, you can deploy applications to the cluster associated with the instance. This topic shows you how to deploy the Bookinfo sample application to an ACK cluster associated with an ASM instance.

Bookinfo application

This topic uses a sample book review application named Bookinfo. The following figure shows its microservice architecture:

The application consists of the following four microservices:

  • Productpage: This microservice calls the Details and Reviews microservices to generate the page.

  • Details: This microservice contains book information.

  • Reviews: This microservice contains book reviews and calls the Ratings microservice.

  • Ratings: This microservice contains rating information from book reviews.

The Reviews microservice has three versions:

  • Version v1 does not call the Ratings service.

  • Version v2 calls the Ratings service and displays ratings as 1 to 5 black stars.

  • Version v3 calls the Ratings service and displays ratings as 1 to 5 red stars.

Prerequisites

Deploy the Bookinfo application

  1. Create a file named bookinfo.yaml with the following content.

    View the full YAML manifest

    apiVersion: v1
    kind: Service
    metadata:
      name: details
      labels:
        app: details
        service: details
    spec:
      ports:
      - port: 9080
        name: http
      selector:
        app: details
    ---
    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: bookinfo-details
      labels:
        account: details
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: details-v1
      labels:
        app: details
        version: v1
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: details
          version: v1
      template:
        metadata:
          labels:
            app: details
            version: v1
        spec:
          serviceAccountName: bookinfo-details
          containers:
          - name: details
            image: registry-cn-hangzhou.ack.aliyuncs.com/ack-demo/examples-bookinfo-details-v1:1.20.1
            imagePullPolicy: IfNotPresent
            ports:
            - containerPort: 9080
    ---
    ##################################################################################################
    # Ratings service
    ##################################################################################################
    apiVersion: v1
    kind: Service
    metadata:
      name: ratings
      labels:
        app: ratings
        service: ratings
    spec:
      ports:
      - port: 9080
        name: http
      selector:
        app: ratings
    ---
    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: bookinfo-ratings
      labels:
        account: ratings
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: ratings-v1
      labels:
        app: ratings
        version: v1
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: ratings
          version: v1
      template:
        metadata:
          labels:
            app: ratings
            version: v1
        spec:
          serviceAccountName: bookinfo-ratings
          containers:
          - name: ratings
            image: registry-cn-hangzhou.ack.aliyuncs.com/ack-demo/examples-bookinfo-ratings-v1:1.20.1
            imagePullPolicy: IfNotPresent
            ports:
            - containerPort: 9080
    ---
    ##################################################################################################
    # Reviews service
    ##################################################################################################
    apiVersion: v1
    kind: Service
    metadata:
      name: reviews
      labels:
        app: reviews
        service: reviews
    spec:
      ports:
      - port: 9080
        name: http
      selector:
        app: reviews
    ---
    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: bookinfo-reviews
      labels:
        account: reviews
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: reviews-v1
      labels:
        app: reviews
        version: v1
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: reviews
          version: v1
      template:
        metadata:
          labels:
            app: reviews
            version: v1
        spec:
          serviceAccountName: bookinfo-reviews
          containers:
          - name: reviews
            image: registry-cn-hangzhou.ack.aliyuncs.com/ack-demo/examples-bookinfo-reviews-v1:1.20.1
            imagePullPolicy: IfNotPresent
            env:
            - name: LOG_DIR
              value: "/tmp/logs"
            ports:
            - containerPort: 9080
            volumeMounts:
            - name: tmp
              mountPath: /tmp
            - name: wlp-output
              mountPath: /opt/ibm/wlp/output
          volumes:
          - name: wlp-output
            emptyDir: {}
          - name: tmp
            emptyDir: {}
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: reviews-v1
    spec:
      ports:
      - port: 9080
        name: http
      selector:
        app: reviews
        version: v1
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: reviews-v2
      labels:
        app: reviews
        version: v2
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: reviews
          version: v2
      template:
        metadata:
          labels:
            app: reviews
            version: v2
        spec:
          serviceAccountName: bookinfo-reviews
          containers:
          - name: reviews
            image: registry-cn-hangzhou.ack.aliyuncs.com/ack-demo/examples-bookinfo-reviews-v2:1.20.1
            imagePullPolicy: IfNotPresent
            env:
            - name: LOG_DIR
              value: "/tmp/logs"
            ports:
            - containerPort: 9080
            volumeMounts:
            - name: tmp
              mountPath: /tmp
            - name: wlp-output
              mountPath: /opt/ibm/wlp/output
          volumes:
          - name: wlp-output
            emptyDir: {}
          - name: tmp
            emptyDir: {}
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: reviews-v2
    spec:
      ports:
      - port: 9080
        name: http
      selector:
        app: reviews
        version: v2
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: reviews-v3
      labels:
        app: reviews
        version: v3
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: reviews
          version: v3
      template:
        metadata:
          labels:
            app: reviews
            version: v3
        spec:
          serviceAccountName: bookinfo-reviews
          containers:
          - name: reviews
            image: registry-cn-hangzhou.ack.aliyuncs.com/ack-demo/examples-bookinfo-reviews-v3:1.20.1
            imagePullPolicy: IfNotPresent
            env:
            - name: LOG_DIR
              value: "/tmp/logs"
            ports:
            - containerPort: 9080
            volumeMounts:
            - name: tmp
              mountPath: /tmp
            - name: wlp-output
              mountPath: /opt/ibm/wlp/output
          volumes:
          - name: wlp-output
            emptyDir: {}
          - name: tmp
            emptyDir: {}
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: reviews-v3
    spec:
      ports:
      - port: 9080
        name: http
      selector:
        app: reviews
        version: v3
    ---
    ##################################################################################################
    # Productpage services
    ##################################################################################################
    apiVersion: v1
    kind: Service
    metadata:
      name: productpage
      labels:
        app: productpage
        service: productpage
    spec:
      ports:
      - port: 9080
        name: http
      selector:
        app: productpage
    ---
    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: bookinfo-productpage
      labels:
        account: productpage
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: productpage-v1
      labels:
        app: productpage
        version: v1
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: productpage
          version: v1
      template:
        metadata:
          annotations:
            prometheus.io/scrape: "true"
            prometheus.io/port: "9080"
            prometheus.io/path: "/metrics"
          labels:
            app: productpage
            version: v1
        spec:
          serviceAccountName: bookinfo-productpage
          containers:
          - name: productpage
            image: registry-cn-hangzhou.ack.aliyuncs.com/ack-demo/examples-bookinfo-productpage-v1:1.20.1
            imagePullPolicy: IfNotPresent
            ports:
            - containerPort: 9080
            volumeMounts:
            - name: tmp
              mountPath: /tmp
          volumes:
          - name: tmp
            emptyDir: {}
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: productpage-v1
    spec:
      ports:
      - port: 9080
        name: http
      selector:
        app: productpage
        version: v1
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: ratings-v1
    spec:
      ports:
      - port: 9080
        name: http
      selector:
        app: ratings
        version: v1
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: details-v1
    spec:
      ports:
      - port: 9080
        name: http
      selector:
        app: details
        version: v1
  2. Run the following command to deploy the sample application in the default namespace.

    kubectl apply -f  bookinfo.yaml

Deploy and configure the ingress gateway

  1. Create a file named bookinfo-gateway.yaml with the following content.

    apiVersion: networking.istio.io/v1beta1
    kind: Gateway
    metadata:
      name: bookinfo-gateway
      namespace: default
    spec:
      selector:
        istio: ingressgateway
      servers:
        - port:
            number: 80
            name: http
            protocol: HTTP
          hosts:
            - '*'
    ---
    apiVersion: networking.istio.io/v1beta1
    kind: VirtualService
    metadata:
      name: vs-demo
      namespace: default
    spec:
      hosts:
        - '*'
      http:
        - name: gw-to-productage
          match:
            - uri:
                exact: /productpage
            - uri:
                prefix: /static
            - uri:
                exact: /login
            - uri:
                exact: /logout
            - uri:
                prefix: /api/v1/products
          route:
            - destination:
                host: productpage
                port:
                  number: 9080
      gateways:
        - bookinfo-gateway
  2. Deploy the ingress gateway.

    kubectl apply -f bookinfo-gateway.yaml

Access the application

You will connect to the Bookinfo productpage service through the gateway that you just configured. 

  1. Get the IP address of the ingress gateway.

    echo $(kubectl -n istio-system get istiogateway ingressgateway -o jsonpath="{.status.GatewayAddress[0]}")
  2. In a browser, visit http://<IP_address_of_the_ingress_gateway>/productpage to view the Bookinfo application.

    The page displays product information for the book "The Comedy of Errors". The Book Details section in the middle of the page lists fields such as ISBN-10, Publisher, Pages, Type, and Language. The Book Reviews section at the bottom displays two reviews with red star ratings from the reviews-v3 version.

    Refresh the page several times. You will notice that the ratings in the Book Reviews section alternate between versions v1, v2, and v3 of the reviews application.

Enable ambient mode for Bookinfo

  1. Log on to the ASM console. In the left-side navigation pane, choose Service Mesh > Mesh Management.

  2. On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose Instance Information > Global Namespace.

  3. In the Dataplane Mode column for the default namespace, click Switch to Ambient Mesh Mode.

    You can switch the Dataplane Mode for the namespace back to sidecar mode on the Global Namespace page at any time.
  4. In your browser, visit http://<IP_address_of_the_ingress_gateway>/productpage to view the Bookinfo application. The application remains accessible. The only difference is that mTLS encryption is enabled for all communication between the Bookinfo application pods.

View the mesh topology

  1. Enable monitoring metric collection.

    1. On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose Observability Management Center > Monitoring metrics.

    2. Click Collect Metrics to Managed Service for Prometheus. In the Confirm dialog box, select the name of your cluster and click OK.

      You can skip this step if you use a self-managed Prometheus instance.
  2. Enable mesh topology.

    1. On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose Observability Management Center > Mesh Topology.

    2. Click Activate, configure the mesh topology with the following parameters, and then click Activate.

      The following configuration is for accessing the topology through an ASM gateway.

      Parameter

      Example value

      Service deployment mode

      Data plane deployment within the Kubernetes cluster.

      When using the managed deployment mode, you can only access the service through a Serverless ASM gateway.

      Observability cluster

      c6118d720xxxxxxxxxxxxxx58410a9c7d0.

      Prometheus scrape address

      This parameter is not required for this example.

      If you use a self-managed Prometheus instance, enter the actual scrape address here.

      If you add multiple clusters to the ASM instance, you must create an aggregation instance and enter the scrape address of the aggregation instance.

      Identity authentication-logon mode

      Token.

      Entry

      ASM .

      • Select an ASM Gateway: Select the name of the ingress gateway, which is ingressgateway in this example.

      • Select an ASM gateway port: Select 443.

        You can also edit the gateway to add a dedicated port for the mesh topology.
  3. Send test traffic to generate the traffic topology graph.

    export GATEWAY_ADDRESS=$(kubectl -n istio-system get istiogateway ingressgateway -o jsonpath="{.status.GatewayAddress[0]}")
    for i in $(seq 1 100); do
      echo "Request $i: $(curl -sSI -o /dev/null -w "%{http_code}" "http://${GATEWAY_ADDRESS}:80/productpage")"
    done
  4. On the Mesh Topology page, click Access ASM mesh topology next to Topology address. In the Logon Method section, click View the logon token and copy the token. On the Kiali page, paste the token into the Token field and click Log in.