All Products
Search
Document Center

Container Compute Service:Use custom domain names in Knative

Last Updated:Apr 28, 2026

By default, Knative Service domain names use the format '{route}.{namespace}.{default-example.com}', where '{default-example.com}' is the default suffix, typically example.com. This topic shows you how to use a custom domain name to enable more flexible routing. ACS Knative lets you set a global custom domain for all Knative Services by using a ConfigMap, or map a unique domain to a single Knative Service by using a DomainMapping.

Prerequisites

Configure a global custom domain

To use the same domain suffix for all Knative Services in ACS Knative, follow these steps.

  1. Run the following command to edit the config-domain ConfigMap in the knative-serving namespace:

    kubectl edit cm config-domain --namespace knative-serving
  2. Modify the configuration file.

    Replace the default domain example.com with your custom domain name and save the file. This example uses mydomain.com as the custom domain name.

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: config-domain
      namespace: knative-serving
    data:
      mydomain.com: "" # This example uses mydomain.com. In production, replace this with your own domain name.
  3. Run the following command to verify that the new domain 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

    The output indicates that the custom domain has taken effect.

  4. Add a DNS record that maps your custom domain to the IP address of the Knative gateway.

  5. Run the following command to access the Knative Service by using the custom domain name:

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

    Expected output:

    Hello Knative!

    This output indicates that the custom domain is configured correctly and the Knative Service is responding to requests.

Configure a custom domain for a single service

To set a specific domain name for a Knative Service, use one of the following methods.

Console

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

  2. On the Clusters page, click the name of the target cluster. In the left navigation pane, choose Applications > Knative.

  3. On the Knative page, click the Services tab, and then find and click the name of your service.

  4. On the service details page, click Access Control in the upper-right corner and configure a custom domain name for the service as prompted.

Kubectl

Use a DomainMapping to assign a specific domain to a service and enable flexible routing with an Ingress controller.

  1. Run the following command to create a file named helloworld.knative.top.yaml:

    vi helloworld.knative.top.yaml
  2. Add the following YAML content to the file, and then save and close the editor:

    apiVersion: serving.knative.dev/v1beta1
    kind: DomainMapping
    metadata:
      name: helloworld.knative.top.mydomain.com # Set the domain name. In production, replace this with your domain name.
      namespace: default # Set the namespace. This must be the same namespace as your service.
    spec:
      ref:
        name: helloworld-go # The name of the target service.
        kind: Service
        apiVersion: serving.knative.dev/v1
  3. Run the following command to apply the helloworld.knative.top.yaml file:

    kubectl apply -f helloworld.knative.top.yaml

    Expected output:

    domainmapping.serving.knative.dev/helloworld.knative.top created
  4. Run the following command to verify the DomainMapping:

    kubectl get domainmapping helloworld.knative.top

    Expected output:

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

    The output indicates that the custom domain has taken effect.

  5. Add a DNS record that maps your custom domain to the IP address of the Knative gateway. For more information, see Add a DNS record.

  6. Run the following command to access the Knative Service by using the custom domain name:

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

    This output indicates that the custom domain is configured correctly and the Knative Service is responding to requests.

Next steps