Services Flashcards
What is a service in kubernetes ?
Service is nothing but the Networking layer by which we can access one or more PODS.
Can we rely on IP address of a POD to communicate with same ?
No.
If a POD is replaced, its IP address also gets changed.
How should we access a POD, if it’s IP address keeps changing ?
using “Service”.
Can we find out the IP address of a POD before it’s scheduling ?
No.
IP address is always allocated to the POD, once it gets scheduled. Hence, we cannot share same before it’s scheduling.
What are the roles of a Service in Kubernetes ?
- Accept the request from external user and pass same to one of POD
- Load balance the request
How a Service knows to which POD it needs to pass the request ?
Using Labels.
Both POD and Service must be using the “same” label to bound themselves. The label is the only way by which a Service load balances the requests between PODs.
Does IP address of a service keeps changing ?
No, it remains fixed.
On which Networking layer, does Service object works ?
Layer 4 (TCP/UDP over IP)
How a frontend POD can communicate with Backend POD ?
The Frontend POD can call the IP address of Service which abstracts the accessiblity of Backend PODs.
What are the different types of Services available in Kubernetes ?
- ClusterIP service
- NodePort Service
- LoadBalancer Service
- ExternalName service
Can we access the “clusterIP” service from outside the K8 cluster ?
No.
ClusterIP service can only be accessed within the K8 cluster.
What’s a clusterIP service ?
ClusterIP services is a K8 service which exposes the PODs within the cluster IPs.
How a POD belongs to one service can access another POD belongs to another service ?
Using “Cluster IP” service.
What’s a Node Port Service ?
NodePort Service is a K8 Service which exposes the PODs on Node’s IP address at a static port.
Can we access a POD using NodePort service ?
Yes.
It provides access to POD via Node’ IP and static port
Can a POD be able to access another POD using NodePort Service ?
No.
For accessing another service within the Cluster, Cluster IP service is needed.
What’s a LoadBalancer Service ?
LoadBalancer Service is a service which exposes the PODs on an external Load Balancer.
Do we need NodePort Service and Cluster IP service after creation of LoadBalancer Service ?
Yes.
During creation of LoadBalancer Service, NodePort Service and ClusterIP services gets automatically created.
What’s an externalName Service ?
ExternalName service is the K8 service which “abstracts” any external service outside the cluster.
How to perform port-forward on a POD using kubectl ?
> > > kubectl port-forward pod/my-nginx 8080:80
How to perform port-forward on a deployment using kubectl ?
> > > kubectl port-forward deployment/my-nginx 8080
How to perform port-forward on a service using kubectl ?
> > > kubectl port-forward service/my-nginx 8080
Create the Service manifest template ?
apiVersion: apps/v1
kind: Service
metaData:
spec:
type:
selector:
ports
What are the different types of the service we can provide in “service manifest”
- ClusterIP
- NodePort
- LoadBalancer