Services and Ingress in Kubernetes

Hiransanjeewaa
3 min readAug 10, 2023

--

What is Services and Ingress in Kubernetes | Cluster-Node Architecture | Load balancing | NodePort | Service Discovery

It’s been a fabulous week with Kubernetes . I have learned many core concepts in Kubernetes . This Article is about Kubernetes services and Ingress . Let ‘s start with Master — Node Architecture in Kubernetes . In my previous article, I have mentioned key features in Kubernetes compared to docker ,. Kubernetes solves the single host problem in containerization by using master-node architecture . In Kubernetes we have clusters . cluster means set of nodes . Nodes can be physical or virtual machines . Kubernetes installed inside a cluster. Then we have pods . Pod includes containers , instructions to run containers , parameters and storage resources . We can run multiple pods inside a node . Inside a node , we can run one or more containers.

Right let’s see what is a Service in Kubernetes is .There are 3 main features in a Service.

1. Service Discovery

2. Load Balancing

3. Exposing Applications to outside

When a pod starts each time it gets different ip address. Tracking pods using Ip addresses can be difficult when there are more nodes and pods available. So we need to track pods without using Ip addresses . These pods only accessed from inside the cluster . We need a mechanism to distribute traffic over the pods (load balancing) . This where Kubernetes service comes in to act .

Kubernetes discover pods using labels and selectors . There are mainly three types of services in Kubernetes.

1. Cluster Ip

2. NodePort

3. Load Balancer

Using cluster ip type service, we can access pods from inside the cluster . NodePort type allows to access pods from the organization. If we have a cluster in a local machine we can access nodes from our local network. But we cannot access publicly using NodePort mode. In load balancer mode with help of Cloud controller manager and services in cloud environments we can assign a public ip to our cluster .

Now we have load balancing , service discovery and we can access application publicly also . why we need ingress ?

· Services only support round robin load balancing.

· Each service needs a public IP and public Ips are costly .

There can be times where we need enterprise level load balancing methods like relational load balancing , sticky sessions , path, and domain load balancing , whitelisting and blacklisting. By using ingress, we can accomplish these enterprise level load balancing. Without ingress we need public ip for every service . By using ingress, we can have one public ip for few services . Thank you for reading.

--

--

Hiransanjeewaa

Software Engineering Undergraduate — University of Kelaniya