All Products
Search
Document Center

Alibaba Cloud Service Mesh:Set a custom domain name in Knative on ASM

Last Updated:Feb 23, 2024

The default domain name of a Knative Service is example.com. The default DNS name is in the following format: {Service name}.{Namespace in which the Service resides}.{Default domain name}. If you want to associate a Knative Service with a domain name of an enterprise or maintain the consistency and professionalism of domain names, you can use a custom domain name as the default domain name in Knative on ASM. This topic describes how to set a custom domain name in Knative Serving, associate the custom domain name with the helloworld-go service, and access the helloworld-go service by using the new custom domain name.

Prerequisites

A Knative Service is created by using Knative on ASM.

Use a custom domain name as the default domain name in the ASM console

  1. Log on to the ASM console. In the left-side navigation pane, choose Service Mesh > Mesh Management.

  2. On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose Ecosystem > Knative on ASM.

  3. In the Knative components section of the Knative on ASM page, click edit to the right of Service domain name suffix, enter the desired domain name (aliyun.com in this example), and then click confirm edit.

Access the Knative Service by using the new custom domain name

After an application is deployed, Knative automatically updates all Knative Services and routes based on the ConfigMap.

  1. Add the information about the new custom domain name that you want to visit to the hosts file.

    The following sample code shows the content that is to be added to the hosts file. Replace xx.xx.xxx.xx with the IP address of the gateway that you actually access. For more information about how to obtain the gateway address, see Step 3: Query the gateway address in Use Knative on ASM to deploy a serverless application.

    xx.xx.xxx.xx helloworld-go.default.aliyun.com
  2. Access the helloworld-go service by using the new custom domain name.

    • Access the helloworld-go service by running the following command

      curl http://helloworld-go.default.aliyun.com
      
      # Expected output:
      Hello Knative!
    • Access the helloworld-go service by visiting the following website

      Enter https://helloworld-go.default.aliyun.com in a browser to directly access the service.

References

  • A Service Mesh (ASM) gateway supports HTTPS and allows you to dynamically load certificates. When you use Knative on ASM, you can use an ASM gateway to access the Knative Service over HTTPS. For more information, see Use an ASM gateway to access a Knative Service over HTTPS.

  • Knative on ASM allows you to perform a canary release based on traffic splitting for a Knative Service. When you create a Knative Service, Knative automatically creates the first Revision for the Service. Whenever the configuration of the Knative Service changes, Knative creates a new Revision and modifies the percentage of traffic that is distributed to different Revisions to implement a canary release. For more information, see Perform a canary release based on traffic splitting for a Knative Service by using Knative on ASM.

  • Knative Serving adds the Queue Proxy container to each pod. The Queue Proxy container sends concurrency metrics of the application containers to KPA. After KPA receives the metrics, KPA automatically adjusts the number of pods provisioned for a Deployment based on the number of concurrent requests and related autoscaling algorithms. For more information, see Enable autoscaling of pods based on the number of requests.