In Kubernetes, a Service is an abstraction which represents a logical set of Pods and a policy by which to access them.
Although each Pod has a unique IP address, those IPs are not exposed outside the cluster without a Service.
The point is that Pods in Kubernetes are “mortal” – every time a Pod dies for some reason, a new Pod is created in its place with a different IP address, so IP addresses of Pods cannot be called persistent and stable.
The idea of a Service is to group a set of Pod endpoints (back-end) into a single resource (front-end) with a persistent IP addresses that can be exposed in different ways depending on a
In this note i will show how to list Services in Kubernetes using the
kubectl command and how to get detailed information about each Service in different formats.
Cool Tip: List & Change Namespaces in Kubernetes! Read more →
Get Kubernetes Services using Kubectl
List all Services:
$ kubectl get services
Show the particular Service:
$ kubectl get service <NAME>
Get the Service details:
$ kubectl describe services - or - $ kubectl describe service <NAME>
Get the Service details in YAML format:
$ kubectl get services -o yaml - or - $ kubectl get service <NAME> -o yaml
Cool Tip: List Nodes in Kubernetes cluster! Read more →
Types of Services
There are five types of Services in Kubernetes:
|ClusterIP||Exposes the Service on an internal IP, which can be accessed by other apps in the cluster, without allowing external access. This is the default
|NodePort||Exposes the Service on each Node’s IP at a static port (the
|LoadBalancer||Exposes the Service externally using a cloud provider’s load balancer.
|ExternalName||Maps the Service to the contents of the
|Headless||Sometimes you don’t need load-balancing and a single Service IP. In this case, you can create what are termed “headless” Services, by explicitly specifying
Cool Tip: List Pods in Kubernetes cluster! Read more →