Application Load Balancer (ALB) runs at the application layer and supports protocols such as HTTP, HTTPS, and Quick UDP Internet Connections (QUIC). ALB offers high elasticity and can process a large amount of network traffic at Layer 7. In addition, ALB supports canary releases based on headers and cookies. This topic describes how to use ALB Ingresses in Knative.
Step 1: Configure an ALB Ingress
You can configure an ALB Ingress by using one of the following methods:Method 1: Select the ALB Ingress when you deploy Knative
- Log on to the ACK console.
- In the left-side navigation pane of the ACK console, click Clusters.
- On the Clusters page, find the cluster that you want to manage and click the name of the cluster or click Details in the Actions column. The details page of the cluster appears.
- In the left-side navigation pane of the details page, choose .
- On the Components tab, click Deploy Knative.
- On the Deploy Knative page, select ALB and select at least two vSwitches. For more information about how to create vSwitches, see Create a vSwitch.
- After you complete the configurations, click Deploy.
If Knative is deployed, you can modify the configuration file of Knative to specify an ALB Ingress.
- Run the following command to modify the configuration file named config-network.yaml:
kubectl -n knative-serving edit configmap config-network
- Refer to the following template to modify
vswitch-idsin the config-network.yaml file. Then, save the change and exit.
vswitch-idsspecifies the IDs of the vSwitches that are used by the ALB Ingress. You must specify at least two vSwitches IDs and the vSwitches must be deployed in different zones. For more information about the regions and zones that are supported by ALB, see Supported regions and zones.
apiVersion: v1 data: ... vswitch-ids: 'vsw-uf6kbvc7mccqia2pi****,vsw-uf66scyuw2fncpn38****' ... kind: ConfigMap metadata: name: config-network namespace: knative-serving
Step 2: Access a service by using the ALB Ingress
- Run the following command to query the domain name of the ALB instance:
kubectl get albconfig knative-internet -ojson jq .status.loadBalancer.dnsname
- Run the following command to access a Service:
curl -H "Host: helloworld-go.default.example.com" http://alb-ijvf32ubve64wz****.cn-shanghai.alb.aliyuncs.com
Configure a CNAME record
ALB allows you to add a CNAME record to map your domain names to the publicly accessible domain name of the ALB instance. This allows you to access network resources in a convenient manner. For more information, see Configure a CNAME record.