Kubernetes-ingress

Ingress

As we all know to expose pods to outside world we use different services like Node-port, and Load-balancer, but here when we use Load-balancer service requires its own load-balancer with its own IP-Address, But Ingress requires only one even providing access to multiple services.

understanding an ingress controller is required ---------------------------------------------------------------------------------------

Before going to the feature of what ingress provides, let me explain that to make ingress resources work, an ingress controller needs to be running in the cluster. Different kubernetes environments use different implemantations of the controller, but several don't provide a controller at all. For example Azure kubernetes services azure's own HTTP Load-Balancing features to provide the ingress functionality. But Minikube didn't provide a controller out-side world, but you can include an add-on that can be enabled using following command

"minikube addons enable ingress"

Enable the ingress add-on so you can see ingress in action

Now creat an ingress resource. vi ingressresource.yaml

This defines an ingress with a single rule, which makes sure all HTTP requests recieved by ingress controller, in which the host dashboard.com is requested, will be sent to the kubernetes-dashboard service on port 80

now after apply this command # kubectl apply -f <file-nam.yaml>

Accessing the service through the ingress

NOTE: Ingress controllers on cloud providers (In Azure, for example) require the Ingress to point to a Node-Port service, But that's not a requirement of kubernetes itself

Understanding how ingress work

How the client conneccted to one of the pods through the ingress controller. The client first performed a Domain-name of Dashboard.com, and the DNS server returned the IP address of the ingress controller. The client than sent an HTTP request to the ingress controller and specified Dashboard.com in the Host-header. FRom that header, the controller determined which service the client is trying to access, looked up the pods IP's through the end-points object associated with the service, and forwarded the client request to one of the pods

Note: Not only a single service, we can Expose multiple services through the same Ingress