All Products
Search
Document Center

Container Compute Service:Use ASM Ingresses in Knative

Last Updated:Jan 14, 2025

In large-scale traffic management scenarios for distributed systems or microservices applications, especially in scenarios where Istio is used as the service mesh framework, we recommend that you create ASM Ingresses to distribute and route traffic for your Knative Services. ASM Ingresses are compatible with open source Istio. Its control plane component is fully managed, which simplifies service governance. ASM Ingresses can manage routes and traffic splitting among services, authenticate requests sent among services, and monitor service meshes.

Prerequisites

An ASM instance is created and its version is 1.21.6.84 or later. For more information, see Create an ASM instance. When you create an ASM instance, add your ACS cluster to the ASM instance in the Kubernetes Clusters section.

Step 1: Select ASM Ingresses when you deploy a Knative Service

  1. Log on to the ACS console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, find the cluster that you want to manage and click its ID. In the left-side navigation pane of the cluster details page, choose Applications > Knative.

  3. On the Knative page, under the Components tab, click Deploy Knative, then select ASM at the Gateway section, and click Deploy.

    After successful deployment, you can use the ASM in Knative.

Step 2: Access the Knative Service through the ASM Ingress

This example uses a Knative Service to demonstrate how to use ASM to deploy the Service.

  1. Log on to the ACS console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, find the cluster that you want to manage and click its ID. In the left-side navigation pane of the cluster details page, choose Applications > Knative.

  3. Under the Services tab on the Knative page, select Namespace as default, then click Create from Template. Copy and paste the following YAML example into the template, and click Create to create a Service named helloworld-go.

    Important

    Replace {REGION-ID} in the code below with the region ID of your cluster (e.g., cn-beijing) to ensure access and use of the image.

    apiVersion: serving.knative.dev/v1
    kind: Service
    metadata:
      name: helloworld-go
    spec:
      template:
        spec:
          containers:
          - image: registry.{REGION-ID}.aliyuncs.com/knative-sample/helloworld-go:73fbdd56 # Please replace {REGION-ID} with the region of your cluster.
            env:
            - name: TARGET
              value: "Knative"
  4. Under the Gateway column on the Services page, you can get the gateway address of the helloworld-go Service.

  5. Run the following command to access the helloworld-go Service:

    curl -H "host: helloworld-go.default.example.com" http://39.XX.XX.XX # Please use the actual IP and domain name of your gateway.

    Expected output:

    Hello Knative!

    The output indicates that the Service access is successful.

(Optional) Step 3: View the Knative monitoring dashboard

Knative provides out-of-the-box monitoring features. On the Knative page, click the Monitoring Dashboards tab to view the monitoring data of the specified Service. For more information about the Knative dashboard, see View the Knative dashboard.

image.png

References