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.

Prerequisites

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
  1. Log on to the ACK console.
  2. In the left-side navigation pane of the ACK console, click Clusters.
  3. 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.
  4. In the left-side navigation pane of the details page, choose Applications > Knative.
  5. On the Components tab, click Deploy Knative.
  6. 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.
  7. After you complete the configurations, click Deploy.
Method 2: Modify the configuration file of Knative

If Knative is deployed, you can modify the configuration file of Knative to specify an ALB Ingress.

  1. Run the following command to modify the configuration file named config-network.yaml:
    kubectl -n knative-serving edit configmap config-network
  2. Refer to the following template to modify vswitch-ids in the config-network.yaml file. Then, save the change and exit. vswitch-ids specifies 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

  1. Run the following command to query the domain name of the ALB instance:
    kubectl get albconfig knative-internet -ojson  jq .status.loadBalancer.dnsname

    Expected output:

    "alb-ijvf32ubve64wz****.cn-shanghai.alb.aliyuncs.com"
  2. 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.