apiVersion: serving.knative.dev/v1alpha1
kind: DomainMapping
metadata:
name: <domain_name> (1)
namespace: <namespace> (2)
spec:
ref:
name: <target_name> (3)
kind: <target_type> (4)
apiVersion: serving.knative.dev/v1
You can customize the domain for your Knative service by mapping a custom domain name that you own to a Knative service. To map a custom domain name to a custom resource (CR), you must create a DomainMapping
CR that maps to an Addressable target CR, such as a Knative service or a Knative route.
You can customize the domain for your Knative service by mapping a custom domain name that you own to a Knative service. To map a custom domain name to a custom resource (CR), you must create a DomainMapping
CR that maps to an Addressable target CR, such as a Knative service or a Knative route.
The OpenShift Serverless Operator and Knative Serving are installed on your cluster.
Install the OpenShift CLI (oc
).
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.
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 IP address of the OpenShift Container Platform cluster. |
Create a YAML file containing the DomainMapping
CR in the same namespace as the target CR you want to map to:
apiVersion: serving.knative.dev/v1alpha1
kind: DomainMapping
metadata:
name: <domain_name> (1)
namespace: <namespace> (2)
spec:
ref:
name: <target_name> (3)
kind: <target_type> (4)
apiVersion: serving.knative.dev/v1
1 | The custom domain name that you want to map to the target CR. |
2 | The namespace of both the DomainMapping CR and the target CR. |
3 | The name of the target CR to map to the custom domain. |
4 | The type of CR being mapped to the custom domain. |
apiVersion: serving.knative.dev/v1alpha1
kind: DomainMapping
metadata:
name: example-domain
namespace: default
spec:
ref:
name: example-service
kind: Service
apiVersion: serving.knative.dev/v1
apiVersion: serving.knative.dev/v1alpha1
kind: DomainMapping
metadata:
name: example-domain
namespace: default
spec:
ref:
name: example-route
kind: route
apiVersion: serving.knative.dev/v1
Apply the DomainMapping
CR as a YAML file:
$ oc apply -f <filename>