This is a cache of https://docs.openshift.com/serverless/1.33/knative-serving/config-custom-domains/create-domain-mapping-kn.html. It is a snapshot of the page at 2024-11-18T16:40:42.026+0000.
Custom domains using the Knative CLI - Configuring custom domains for Knative services | Serving | Red Hat OpenShift Serverless 1.33
×

You can customize the domain for your Knative service by mapping a custom domain name that you own to a Knative service. You can use the Knative (kn) CLI to create a DomainMapping custom resource (CR) that maps to an Addressable target CR, such as a Knative service or a Knative route.

Creating a custom domain mapping by using the Knative CLI

Prerequisites
  • The OpenShift Serverless Operator and Knative Serving are installed on your cluster.

  • You have created a Knative service or route, and control a custom domain that you want to map to that CR.

    Your custom domain must point to the dns of the OpenShift Container Platform cluster.

  • You have installed the Knative (kn) CLI.

  • You have created a project or have access to a project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.

Procedure
  • Map a domain to a CR in the current namespace:

    $ kn domain create <domain_mapping_name> --ref <target_name>
    Example command
    $ kn domain create example.com --ref showcase

    The --ref flag specifies an Addressable target CR for domain mapping.

    If a prefix is not provided when using the --ref flag, it is assumed that the target is a Knative service in the current namespace.

  • Map a domain to a Knative service in a specified namespace:

    $ kn domain create <domain_mapping_name> --ref <ksvc:service_name:service_namespace>
    Example command
    $ kn domain create example.com --ref ksvc:showcase:example-namespace
  • Map a domain to a Knative route:

    $ kn domain create <domain_mapping_name> --ref <kroute:route_name>
    Example command
    $ kn domain create example.com --ref kroute:example-route