Having an application deployed on a Kubernetes cluster consisting of multiple microservices, you may want to expose some of them to be accessible through the internet. While it’s obviously for your web app service, maybe you have some additional APIs that you want to expose.
In the world of Kubernetes, any connection to one of your microservices is done using the Service resource. Using the type LoadBalancer of the Kubernetes Service resource leverages the underlying cloud provider to create a cloud provider-specific load balancer for exposing the microservice through an external IP. The problem with that approach is that each microservice would be exposed under a separate IP address.
It would be much more convenient to have them exposed under one and the same host while having different paths to reach the dedicated microservice, right?
This article shows how to do that with a Kubernetes Cluster on Azure and Traefik and is a follow-up to my article about achieving the same using the Azure Application Gateway. A lot of content will be based on that article.
Microservices can be exposed inside and outside of Kubernetes using the Kubernetes Service resource. So far, so good. But as already said, if we want to expose them outside the cluster, using the Service resource with the type LoadBalancer, we end up having different IPs for each microservice. This does not want we want, instead, we want to have them exposed under one and the host using different paths.
This is where the Kubernetes Ingress resource comes in handy. Think of an Ingress like a layer on top of Kubernetes Services. It is the single point of entrance for traffic hitting our microservices, which routes traffic to different Kubernetes Services based on specified rules.
The concept of Kubernetes Ingress resource is like an Abstraction. In order to make use of a Kubernetes Ingress, you have to install a specific Ingress Controller. There are plenty of different Implementations of the Kubernetes Ingress Abstraction out there. Nginx and Traefik Ingress are two of them which are very popular in the Kubernetes and Open Source Community, just to name some.
And then of course we have Cloud Providers, where you can use resources like Load Balancers and Gateways as a Kubernetes Ingress. Anyways, in this article, we will focus on the Traefik_ Ingress_.
#microservices #azure-kubernetes-service #ingress #kubernetes #azure kubernetes service