All Products
Search
Document Center

Container Compute Service:Specify a custom domain name for a Knative Service

Last Updated:Mar 26, 2026

By default, each Knative Service gets a domain name in the {route}.{namespace}.example.com format. This topic explains how to replace example.com with your own domain name.

Choose the approach that fits your use case:

ApproachWhen to use
Global domain nameApply the same domain suffix to all Knative Services in the cluster. Configure once in the config-domain ConfigMap.
Per-service domain nameMap a specific domain name to a single Knative Service, without affecting other Services. Create a DomainMapping resource, or use the ACS console.

Prerequisites

Before you begin, ensure that you have:

Set a global domain name

Setting a global domain name applies the same domain suffix to all Knative Services in the cluster.

  1. Open the config-domain ConfigMap for editing:

    kubectl edit cm config-domain --namespace knative-serving
  2. Replace example.com with your domain name and save. The following example uses mydomain.com:

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: config-domain
      namespace: knative-serving
    data:
      mydomain.com: ""
  3. Verify that the new domain name is applied:

    # Replace helloworld-go with the name of your Knative Service.
    kubectl get route helloworld-go --output jsonpath="{.status.url}" | awk -F/ '{print $3}'

    Expected output:

    helloworld-go.default.mydomain.com
  4. Add the IP address of the Knative gateway to the resolution settings of the custom domain name in the Alibaba Cloud DNS console.

  5. Access the Knative Service through the custom domain name:

    curl http://helloworld-go.default.mydomain.com

    Expected output:

    Hello Knative!

Set a domain name for a single Knative Service

Use this approach to map a specific domain name to one Knative Service, while leaving other Services unaffected.

Use the console

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

  2. On the Clusters page, find your cluster and click its ID. In the left-side navigation pane, choose Applications > Knative.

  3. On the Knative page, click the Services tab, then click the name of the Service you want to configure.

  4. In the upper-right corner, click Access Control and set the parameters as prompted.

Use kubectl

  1. Create a file named helloworld.knative.top.yaml:

    vi helloworld.knative.top.yaml
  2. Add the following content, save, and exit:

    apiVersion: serving.knative.dev/v1beta1
    kind: DomainMapping
    metadata:
      name: <domain-name>
      namespace: <namespace>
    spec:
      ref:
        name: <service-name>
        kind: Service
        apiVersion: serving.knative.dev/v1

    Where:

    • <domain-name>: the custom domain name to map to the Knative Service, for example, helloworld.knative.top.mydomain.com.

    • <namespace>: the namespace that contains the Knative Service, for example, default.

    • <service-name>: the name of the Knative Service, for example, helloworld-go.

  3. Apply the manifest:

    kubectl apply -f helloworld.knative.top.yaml

    Expected output:

    domainmapping.serving.knative.dev/helloworld.knative.top created
  4. Verify the DomainMapping:

    kubectl get domainmapping helloworld.knative.top

    Expected output:

    NAME                     URL                              READY   REASON
    helloworld.knative.top   http://helloworld.knative.top    True

    READY: True confirms the custom domain name is in effect.

  5. Add the IP address of the Knative gateway to the resolution settings of the custom domain name in the Alibaba Cloud DNS console.

  6. Access the Knative Service through the custom domain name:

    curl http://helloworld.knative.top.mydomain.com

    Expected output:

    Hello Knative!

What's next