Exposing Ports in Kubernetes Applications
In this article, we will show how to expose applications running in Kubernetes Pods to other applications inside the cluster and the external world. We will discuss the three most common ways of doing so which are Kubernetes Services, LoadBalancers, and Ingress. We will show how they differ from one another and which one to choose according to your application’s requirements.
Note: LoadBalancers are a technically a subtype of Service, but they have unique characteristics and deserve special attention.
Why Services, LoadBalancers and Ingress?
On traditional servers without Kubernetes, communication happens between applications using DNS which is mapped directly to IP addresses. However, in Kubernetes it's not so simple! Applications don't have a single permanent IP address any more.
Kubernetes Services
A Kubernetes Service is a logical abstraction that makes it possible to reach applications running inside ephemeral pods. Services create a single and constant point of entry to a group of pods. Each Service has an IP address and port that never changes while the Service exists.
There are three primary types of Kubernetes services:
- ClusterIP
- NodePort
- LoadBalancer
