Kubernetes Services

We will see different ways of exposing an application outside a Kubernetes Cluster using Service.

Each pod in the Kubernetes cluster gets a unique IP address and is also not exposed to outside the cluster. Suppose there are 2 replicas of front end app and 2 replicas of back end app are running. These applications should work smoothly and this is done by services.

A Service in Kubernetes is an abstract layer by defining a logical set of Pods and enables external traffic exposure. It acts as a bridge between the outside world and the pod by providing a virtual IP address. It exposes virtual IP mapped to pods and allows applications to receive traffic.

A Service is defined using YAML or JSON. The set of Pods targeted by a Service is usually determined by a label selector.

Creating a service will create an endpoint to access the pods/applications.


Services can be exposed in different ways by specifying a type in the spec of the service file.

  1. ClusterIP: Exposes the service within the cluster. Mainly used to communicate within a cluster.

  2. NodePort: Expose the service from outside the cluster. It's a superset of ClusterIP.

  3. LoadBalancer: It's a superset of NodePort and it is used by the cloud providers by assigning a fixed, external IP to the service.

  4. ExternalName: Here the DNS comes into the picture. It maps the services to the DNS record.

By default:

  • ClusterIP service is used.

  • Service can run only on ports in the range (30,000 to 32,767)

Soon will see demo, stay tuned!!

Keep Leaning :)