Use an ASM gateway in Knative
In large-scale distributed systems and microservice application traffic management scenarios, especially where Istio is already in use or planned as the service mesh framework, use a Service Mesh (ASM) gateway to distribute and route traffic for Knative services. ASM gateways are compatible with the community Istio specification, and their control plane components are managed by Container Service for Kubernetes (ACK). This simplifies service governance, including the management of traffic routing and splitting between service invocations, authentication security for communication between services, and mesh observability.
Prerequisites
An ASM instance of version 1.21.6.84 or later is created. For more information, see Create an ASM instance.
When you create the ASM instance, in the Kubernetes Clusters section, add the created ACK managed cluster or ACK Serverless cluster to the ASM instance, and then select Allow data plane cluster KubeAPI to access Istio CR.
Step 1: Deploy an ASM gateway
You can select the ASM (Istio) gateway when you first deploy Knative, or modify the configuration file after Knative is deployed to configure the ASM gateway.
New Knative installation
-
Log on to the ACK console. In the left navigation pane, click Clusters.
-
On the Clusters page, click the name of your cluster. In the left navigation pane, click .
-
On the Knative page, click the Add-ons tab, and then click Deploy Knative. In the Gateway section, select ASM and click Quick Deployment.
After the deployment succeeds, you can use ASM as the service mesh in Knative.
Existing Knative installation
-
Edit the config-network file.
kubectl -n knative-serving edit configmap config-network -
Change
ingress.classtoistio.ingress.networking.knative.dev, and then save the config-network file.apiVersion: v1 data: ... ingress.class: istio.ingress.networking.knative.dev # Use the ASM gateway ... kind: ConfigMap metadata: name: config-network namespace: knative-serving
Step 2: Access a deployed Service through the ASM ingress gateway
This section uses a Knative Service example to demonstrate how to deploy a Service through ASM.
-
Log on to the ACK console. In the left navigation pane, click Clusters.
-
On the Clusters page, click the name of your cluster. In the left navigation pane, click .
-
On the Knative page, click the Services tab, set Namespace to default, click Create from Template, paste the following YAML example into the template, and then click Create to create a Service named helloworld-go.
ImportantReplace
{REGION-ID}in the following code with the region ID of your cluster (for example,cn-beijing) to make sure that the image can be correctly accessed and used.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" -
On the Services page, in the Gateway column, get the gateway address of the helloworld-go Service.
-
Run the following command to access the helloworld-go Service.
curl -H "Host: helloworld-go.default.example.com" http://39.XX.XX.XX # Replace the gateway IP address and domain name with your actual data.Expected output:
Hello Knative!The expected output indicates that the Service is accessed successfully.
(Optional) Step 3: View service monitoring data
Knative provides out-of-the-box observability. On the Knative page, click the Monitoring Dashboards tab to view the monitoring data of the target Knative Service. See View the Knative service monitoring dashboard.
Related documents
To enable custom domains for Knative Services, see Use custom domains and paths.
Configure HTTPS certificate access for Knative Services.
Deploy gRPC services in Knative to improve network efficiency.
Configure port probing in Knative to monitor the health status and availability of Knative Services.
If your ECI instances need to connect to the Internet, bind an EIP. For more information, see Associate an EIP with the elastic container instance on which a Knative Service runs.