Debug School

Kumar
Kumar

Posted on

Kubernetes Resources - Services

What are Kubernetes Services?

Kubernetes Services are a way to expose the functionalities/API provided by the workloads (containers) hosted in the cluster. There are many types of services, ClusterIP Service, NodePort Service, LoadBalancer Service. Each have its uses.

Why do we need them and how they work?

Kubernetes workloads (containers) run in an overlay network that is internal to the Kubernetes cluster. In order to expose the functionalities/APIs provided by these workloads (containers), it becomes imperative that Kubernetes provides a mechanism. Kubernetes has the concept of Services for this purpose.

ClusterIP Service

Expose the pod/deployment/rc across the cluster (all nodes). This provides an abstraction from changing Pod IP addresses (when pods get replaced). The ClusterIP Service gets a fixed IP address and based on label selectors workloads are matched and their pod IPs are used as endpoints by the ClusterIP Service to forward traffic. In the event of a Pod going down and replaced, the Kubernetes cluster will immediately replace the old the Pod IP with the newly replaced Pod IP.

NodePort Service

Expose the pod/deployment/rc externally/outside of the cluster. This type of service contains a ClusterIP service and a Node port mapping. A Node Port mapping will result in a decided port opened in all Nodes (Worker+Master) and that will forward traffic to the ClusterIP Service.

LoadBalancer Service

Create and expose the LoadBalancer in the hosting platform (cloud/on prem). This type of service includes a NodePort Service and the automation integration with the hosting compute platform for obtaining a external LoadBalancer configured. This is used to create a LoadBalancer in the hosting cloud platform to forward traffic to the NodePort service.

Top comments (0)