apiVersion: serving.knative.dev/v1alpha1
kind: DomainMapping
metadata:
name: <domain_name> (1)
namespace: <namespace> (2)
spec:
ref:
name: <service_name> (3)
kind: Service
apiVersion: serving.knative.dev/v1
Knative services are automatically assigned a default domain name based on your cluster configuration. For example, <service_name>.<namespace>.example.com
.
You can map a custom domain name that you own to a Knative service by creating a DomainMapping
custom resource (CR) for the service.
You can also create multiple CRs to map multiple domains and subdomains to a single service.
To map a custom domain name to a service you must create a DomainMapping
custom resource (CR).
The OpenShift Serverless Operator and Knative Serving are installed on your cluster.
You have created a Knative service and control a custom domain that you want to map to that service.
Your custom domain must point to the DNS of the OpenShift Container Platform cluster. |
Create a YAML file containing the DomainMapping
CR in the same namespace as the Knative service you want to map to:
apiVersion: serving.knative.dev/v1alpha1
kind: DomainMapping
metadata:
name: <domain_name> (1)
namespace: <namespace> (2)
spec:
ref:
name: <service_name> (3)
kind: Service
apiVersion: serving.knative.dev/v1
1 | The custom domain name that you want to map to the service. |
2 | The namespace of both the DomainMapping CR and the Knative service. |
3 | The name of the service to map to the custom domain. |
Apply the DomainMapping
CR as a YAML file:
$ oc apply -f <filename>