About Services in – Kubernetes

What is a Service?

Ans: 

  • Also define as policies for their access
  • A label selector that locates pods
  • The clusterIP IP address and assigned port number
  • Optional mapping of incoming ports to a targetPort

What is the types Services?

Ans:

  • ClusterIP. Exposes a service which is only accessible from within the cluster.
  • NodePort. Exposes a service via a static port on each node’s IP.
  • LoadBalancer. Exposes the service via the cloud provider’s load balancer.
  • ExternalName. Maps a service to a predefined externalName field by returning a value for the CNAME record.

What is the use of service named with “kubernetes” in default namespace?

Ans: It is used to forward the request to master node. So, all the request to kubernetes from cluster will be sent to end point ip.

How services works?

A Kubernetes service is a logical collection of pods in a Kubernetes cluster. We can define a K8s service as an abstract way to load balance across the pods and expose an application deployed on a set of Pods. Moreover, using the inbuilt service mechanism in Kubernetes eliminates the need for implementing a separate service discovery mechanism.