Making knative services available with host ip

Viewed 26

I am exploring knative for some microservices i have. I was successful in setting up knative locally by using the quickstart plugin, KinD and have my containers up and running in the cluster. I was also given a URL by knative to access my service.

home@udit:~$ kn service list
NAME          URL                                             LATEST              AGE   
CONDITIONS   READY   REASON
kairon-chat   http://kairon-chat.default.127.0.0.1.sslip.io   kairon-chat-00001   21h   
3 OK / 3     True    
home@udit:~$ curl http://kairon-chat.default.127.0.0.1.sslip.io
Server Running
home@udit:~$ 

This all is good. However, I want this service to be accessible with the host ip and the port (by host, I mean the machine that runs docker) similar to how a webserver is accessible with host ip and port. Is there any way to facilitate this? I was hoping for a way where we could map host ports with ports on kubernetes similar to how we do when deploying docker images.

1 Answers

Knative uses the HTTP Host header to distinguish traffic intended for different services. This allows you to use a single IP address and port to support multiple services at the same time.

If you expose your HTTP load balancer service (probably kourier if you are using the quickstart configuration) using a node port or load balancer service type, you can then change the default DNS domain to match your client's IP. The default 127.0.0.1.sslip.io domain uses a service from sslip.io that lets you make up additional subdomains based on your IP address if you don't have your own DNS server. You can also use a wildcard DNS record to point to the exposed host IP.

Related