Kubernetes Services

Service Types

A service in Kubernetes symbolizes a collection of pods that are each running an application or functional element. Applications running in pods are made available to the network by Kubernetes services so that other pods or external clients can access them. Load balancing, service discovery, and health checking are all capabilities of services. The Kubernetes control plane ensures that the service is functioning as intended. Typically, YAML files are used to create Kubernetes services and define the desired state of the service.

 

  • ClusterIP:

 

 

Screenshot from 2023-01-24 16-42-10

 

The default service type in Kubernetes is called ClusterIP. In the cluster, it generates a virtual IP (VIP) that can be used to access the pods housing the service. The VIP can't be accessed by outside clients because it can only be accessed from within the cluster.

 

Screenshot from 2023-01-24 22-19-58

 

 

 

  • LoadBalancer:


Screenshot from 2023-01-24 16-46-58

The service of this type establishes a Load Balancer in the cluster that directs traffic to the pods that support the service. When you want to expose an application to clients outside your organization, this kind of service is typically used. Read more about here

 

Screenshot from 2023-01-24 22-19-25-1

 

 

 

  • NodePort:


Screenshot from 2023-01-24 17-06-42

Each node in the cluster that implements this kind of service creates a port that can be used to access the pods that power it. Usually between 30000 and 32767, the port number is configurable. All nodes in the cluster have access to the NodePort service, which is also accessible from outside the cluster.

 

Screenshot from 2023-01-24 22-22-23

 

 

  • ExternalName:

Screenshot from 2023-01-24 16-51-03

In the cluster's DNS, this kind of service creates a CNAME record that can be accessed to access an external service. When you want to use an external service from within the cluster without making it accessible to the internet, this kind of service is typically used.

 

Screenshot from 2023-01-24 22-53-43