services in kubernetes

What is a Service?
-a type of kubernetes resource

  • responsible for exposing an interface to pods
  • enables network access from either within the cluster or between external processes and the service.

What are the types Services?
1.ClusterIP
– exposes a service which is only accessible from within the cluster
2.NodePort
– exposes a services via static port on each node’s IP which help to access service from outside the cluster
3.LoadBalancer
– exposes the service via the cloud provider’s load balancer
4.ExternalName
– Maps a service to a predefined externalName field

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

  • forwards requests to the Kubernetes master ( Typically kubernetes API server)
    -all the requests to the kubernetes.default service from the cluster will be routed to the configured Endpoint IP.
    -kubernetes master is running at the same IP as the Endpoints IP of kubernetes.default service.

How services works?
-For a service to work, the label selector at the load balancer should match the label selector of the pod so that the endpoint IP can be configured and the services can be accessible accordingly.