Kubernetes Tutorial: Part 5- A Little Bit of Polishing
Ingress

In the last article, we have successfully managed to deploy our application using Minikube and accessed the same via a NodePort Service object with the URL convention <minikube-ip>:<port-number> . But when we are developing a production-grade application, we might have multiple services each running in a different port. And soon it may become quite hazy because we just can't keep track of all the services and their endpoints. Wouldn’t it be better if we have a centralized system that manages external accesses to these services in the cluster which could take care of load balancing, SSL termination of HTTPS traffic and allow us to access the services at fancy name-based virtual hosting? Thanks to Ingress, all these pain points can now be easily managed with its help!

Though Ingress is a very vast topic and quite involved, here we will be just using it to create a Name-Based Virtual Hosting so that we could access our service in a pretty URL instead of the one that we currently have in place.

For us to use Ingress, the cluster must have an Ingress controller running, and it is not set by default. Luckily, Minikube is shipped with an Nginx controller which can be enabled by executing:

minikube addons enable ingress

We can use the following YAML file to create an Ingress:

YAML for Ingress creation

And the same can be created by executing:

kubectl create -f ingress.yaml

The created Ingress object maps the service object-detection-service to the host streamlit.exercise.com (you can think of something more fancier 😛). Since we cannot modify the external DSN server, we have to map Minikube’s IP with the virtual host that we have created, and the same can be achieved by modifying the /etc/hosts . The modified file looks like the one shown below:

partha@jarvis:~$ cat /etc/hosts

127.0.0.1 localhost

<minikube-ip> streamlit.exercise.com

where <minikube-ip> is the IP address of the Minikube which can be obtained by executing minikube ip . And now our service is accessible at:
['Parthasarathy Subburaj']
['Docker', 'Streamlit', 'Kubernetes', 'Object Detection', 'Deployment']