Use an ASM gateway in Knative

更新时间:
复制 MD 格式

For large-scale microservice traffic management, especially if you use or plan to use Istio as your service mesh, we recommend using a Service Mesh (ASM) gateway to route traffic for Knative services. ASM is compatible with community Istio and features a managed control plane to simplify service governance. This includes traffic routing and splitting, securing inter-service communication, and providing mesh observability.

Prerequisites

You have created a Service Mesh (ASM) instance (version 1.21.6.84 or later). For more information, see Create an ASM instance. You have added your Container Service (ACS) cluster to the instance in the Kubernetes Cluster section.

Step 1: Select ASM as the gateway

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

  2. On the Clusters page, click the name of the target cluster. In the left navigation pane, choose Applications > Knative.

  3. On the Knative page, click the Add-ons tab. Click Deploy Knative. In the Gateway section, select ASM, and then click Quick Deployment.

    After a successful deployment, you can use Service Mesh (ASM) in Knative.

Step 2: Access services through the ASM gateway

This section uses a sample Knative Service to demonstrate how to deploy a service with ASM.

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

  2. On the Clusters page, click the name of the target cluster. In the left navigation pane, choose Applications > Knative.

  3. On the Knative page, click the Services tab. Set Namespace to default and click Create from Template. Paste the following YAML into the template editor and click Create to create a service named helloworld-go.

    Important

    Replace {REGION-ID} in the following code with the region ID of your cluster, for example, cn-beijing, to ensure the image is accessible.

    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 # Replace {REGION-ID} with the region ID of your cluster.
            env:
            - name: TARGET
              value: "Knative"
  4. On the Services tab, find the helloworld-go service and copy its address from the Gateway column.

  5. Run the following command to access the helloworld-go service.

    curl -H "Host: helloworld-go.default.example.com" http://39.XX.XX.XX # Replace with your actual gateway IP address and domain name.

    Expected output:

    Hello Knative!

    This output indicates a successful connection.

(Optional) Step 3: View service monitoring data

Knative provides built-in observability features. On the Knative page, click the Monitoring Dashboards tab to view monitoring data for your Knative services. For details about the dashboards, see View the Knative service monitoring dashboard.

image.png

Related documents