Open In App

Kubernetes – Services

Improve
Improve
Like Article
Like
Save
Share
Report

Software deployment, scaling, and management are all automated using Kubernetes, an open-source container orchestration system. K8s is another name for Kubernetes. Kubernetes was initially developed by Google and is now managed by the Cloud Native Computing Foundation. Despite the fact that it now supports CRI-O in addition to the Docker runtime, with which it was first designed to interact. The main objective of Kubernetes is to automate container management’s operational tasks. It comes with built-in functions for rolling out required application modifications and for deploying applications. It is currently utilized by businesses including Google, Spotify, and Capital One.

Services

It can be defined as an abstract way or method of exposing any application running on a set of <a href=”https://www.geeksforgeeks.org/kubernetes-pods/” > pods </a > as a network service. While we are using Kubernetes we don’t need to modify our application to use an unfamiliar service discovery mechanism. Each pod is given its own unique IP address and a single DNS name for sets of Pods and they can be load balanced across them.
Kubernetes Pods are created and destroyed to match the required state of our cluster. In general, Pods are considered non-permanent resources. We can create or destroy pods dynamically. Each pod is assigned its own IP address but during deployment, the set of Pods running in one moment in time could be different from the set of Pods running that application at another time.

Service Resources: 

In Kubernetes, a service can be defined as an abstraction whose main function is to define a logical set of Pods and a policy by which they can be accessed later or when necessary. It is the duty of a Selector to target a set of Pods. Consider a stateless image-processing backend that is currently running with 3 replicas. These replicas are fungible, frontends do not care about the backend use.

Defining a Service:

 In Kubernetes, a Service like a pod is a REST object. Like all other REST objects, we can POST a service definition to its API server which will create a new instance. A valid RFC 1035 label name must be given to the service object. When a Service is defined it is assigned a unique IP address sometimes also called cluster IP which is used by the Service Proxies. Service has the capacity to map any incoming port to a targetPort.
Service Without Selectors: Because the selector services have abstract access to Kubernetes Pods. But when it is used with a corresponding set of EndpointSlices objects and without a selector then a service can abstract other Kinds of backends, this includes those running outside the clusters.
 

 

Config file of service  with Selectors:

 

Multi-Port Service Creation:

 

Types of Services present in Kubernetes:

ClusterIp: 

The main aim is to restrict the service within the cluster. It does so by exposing the service at intervals.

 

NodePort:

This will expose the service on a static port present at the deployed node. A ClusterIP service to that NodePort service can route is automatically created. 

 

Load Balancer:

The NodePort and clusterIP services are automatically Provisioned by which the ELB will rout the traffic forward towards the application. 

 


Last Updated : 30 Mar, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads