kubernetesknativeknative-serving

Knative services URLs


I'm currently evaluating Knative but I've definitely find no way to use path instead of subdomain in the URL for accessing service.

By default, when creating an service, the URL is made like this: http://Name.Namespace.Domain and what I would like to have is something like this http://Domain/Namespace/Name

Does anybody knows if it is possible ? Thanks in advance,

Cédric


Solution

  • Knative uses subdomains rather than URL paths because the underlying container could handle many different URLs, and might encode requests with absolute URLs (which might point to a different function depending on deployment) or relative URLs (which would point within the current application).

    If you want to map multiple Knative services under a single domain name, you can use an Ingress implementation or API server like Kong, Istio, or many others. You will need an HTTP router which can rewrite the Host header to point to the Knative Service's hostname in question; the default Kubernetes Ingress resource doesn't expose this capability.

    If you choose to set this up, you'll also need to decide on a policy for mapping the URL paths: you could either strip the URL paths off when passing them to the Knative Service, or leave them present. It probably makes more sense to strip the URL paths off, since otherwise you'll end up needing to have a dependency between your application code and the namespace and name that you have chosen to deploy it at.

    Other gotchas to watch out for: