We use analytics and cookies to understand site traffic. Information about your use of our site is shared with Google for that purpose. Learn more.
Setting up a custom domain per Service
By default, Knative uses the {route}.{namespace}.{default-domain}
fully qualified domain name for services, where default-domain
is example.com
.
You can change the default-domain
by Setting up a custom domain. You can also set a custom domain per service, by using a custom FQDN for a service, or by using custom domain mapping.
Procedure
-
Edit the
domainTemplate
entry on theconfig-network
configuration:kubectl edit cm config-network --namespace knative-serving
Replace the
domainTemplate
with the following (the spaces must be respected):[...] data: [...] domainTemplate: |- {{if index .Annotations "custom-hostname" -}} {{- index .Annotations "custom-hostname" -}} {{else -}} {{- .Name}}.{{.Namespace -}} {{end -}} .{{.Domain}}
Save and close your editor.
-
In a service definition, add the
custom-hostname
annotation:apiVersion: serving.knative.dev/v1 kind: Service metadata: name: hello-world annotations: # the Service FQDN will become hello-world.{default-domain} custom-hostname: hello-world spec: [...]
Apply your changes.
-
Verify that the service was created with the specified hostname:
kubectl get ksvc hello-world NAME URL LATESTCREATED LATESTREADY READY REASON hello-world http://hello-world.example.com hello-world-nfqh2 hello-world-nfqh2 True
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.