From 861298bbbe7e625c0b5dfc7db3aaa7be77f0d98e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Hu=C3=9F?= Date: Fri, 10 Sep 2021 19:12:31 +0200 Subject: [PATCH] Add how to create custom domains with kn domain (#4209) * Add `kn domain` usage for creating a domain mapping. While on it, also added how to enable TLS for the domain mapping. * Update docs/developer/serving/services/custom-domains.md Co-authored-by: Samia Nneji Co-authored-by: Samia Nneji --- .../serving/services/custom-domains.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/developer/serving/services/custom-domains.md b/docs/developer/serving/services/custom-domains.md index 238fde11b..8ed15e73f 100644 --- a/docs/developer/serving/services/custom-domains.md +++ b/docs/developer/serving/services/custom-domains.md @@ -54,6 +54,8 @@ DomainMappings in that namespace to use the domain name. namespaces or for domain names that they do not own. +=== "Apply YAML" + 1. Create a DomainMapping object: 1. Create a YAML file using the following template: @@ -69,11 +71,14 @@ DomainMappings in that namespace to use the domain name. name: kind: Service apiVersion: serving.knative.dev/v1 + tls: + secret: ``` Where: - `` is the domain name that you want to map a Service to. - `` is the namespace that contains both the `DomainMapping` and `Service` objects. - `` is the name of the Service that is mapped to the domain. + - `` is the name of a Secret that holds the server certificate for TLS communication. If this optional `tls:` section is provided, the protocol is switched from HTTP to HTTPS. !!! tip You can also map to other targets as long as they conform to the Addressable contract and their resolved URL is of the form `..`, where `` and `` are the name and namespace of a Kubernetes Service, and ``is the cluster domain. @@ -86,5 +91,19 @@ DomainMappings in that namespace to use the domain name. ``` Where `` is the name of the file you created in the previous step. +=== "kn CLI" + + ``` + kn domain create --ref --tls --namespace + ``` + + Where: + - `` is the domain name that you want to map a Service or Route to. + - `` is the name of the Service or Route that is mapped to the domain. You can use a prefix `ksvc:` or `kroute:` to specify whether to map the domain to a Knative Service or Route. If no prefix is given, `ksvc:` is assumed. Additionally, you can use a `:namespace` suffix to point to a Service or Route in a different namespace than this Domain mapping. E.g. `mysvc` maps to a Service `mysvc` in the same namespace as this mapping, while `kroute:myroute:othernamespace` maps to a Route `myroute` in namespace `othernamespace`. + - `` is optional and if provided enables the TLS protocol. The value specifies the secret that holds the server certificate. + - `` is the namespace where the DomainMapping should be created. By default the DomainMapping is created in the current namespace. + + In addition to creating DomainMappings, `kn domain` can be used to list, describe, update and delete existing DomainMappings. See `kn domain --help` for more information. + 1. Point the domain name to the IP address of your Knative cluster. Details of this step differ depending on your domain registrar.