Fri. Dec 2nd, 2022

Hello Android

All android in one place

Kubernetes Services – All you need to know!

2 min read

Hello, readers! In this article, we will be focusing on Kubernetes Services in detail. So, let us begin!! 🙂

Recommended read – Introduction to Kubernetes Components

What is a Kubernetes Service?

In general, a Kubernetes Service is a k8 object that defines a set of Kubernetes Pods and plans out the rules and policies to access these pods over the network. Thus, it sets up the selectors that enable the interface to be exposed to the pods. This way, it routes out a source for the network access to happen within the cluster or even through an external source over the network.

A Kubernetes Service engages and connects the set of pods to a particular service name and an IP address. This way the network routing between the pods is managed.

Attributes of a k8 Service:

  1. Label selector: It locates the particular pods to which the service would be bound to.
  2. Cluster IP address
  3. Assigned port number
  4. Definitions and specifications of the port
  5. Mapping of the source port requests to the target port.

Types of Kubernetes Services

  1. Cluster IP service: This service exposes the pods to communicate over a network within the cluster range. It exposes the service on an IP address which stays internal to the cluster itself. Thus, the access stays confined within the limits of the cluster and no other application or service can connect to the applications on the specified pods.
  2. NodePort service: It exposes service on every node within a cluster. So, that if even the service is not running on the node, it will route the incoming traffic to that NodePort service. By this, we can access the service from outside the cluster by framing <IP address: NodePort>. Because, it exposes an open port on every node of the cluster.
  3. LoadBalancer service: This service exposes the requested service through the cloud provider’s load balancer.

Kubernetes Service Template

Here, we have created a Cluster IP service ‘service-app’ which would be bound to the pods with the label app = hello-world. Further, it would be exposed on the port 8001 via cluster’s IP address using port 80.

apiVersion: v1
kind: Service
  name: service-app
    app: hello-world
    - protocol: TCP
      port: 80
      targetPort: 8001
      type: ClusterIP


By this, we have come to the end of this topic. Feel free to comment below, in case you come across any questions. For more such posts related to Kubernetes and Docker, Stay tuned with us.

If you wish to know and read about a particular topic, do let us know in the comment section and will give our best to have the topic ready for you.

Till then, Happy Learning! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

Hello android © All rights reserved. | Newsphere by AF themes.