Services Flashcards

1
Q

What is a service in kubernetes ?

A

Service is nothing but the Networking layer by which we can access one or more PODS.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Can we rely on IP address of a POD to communicate with same ?

A

No.
If a POD is replaced, its IP address also gets changed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How should we access a POD, if it’s IP address keeps changing ?

A

using “Service”.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Can we find out the IP address of a POD before it’s scheduling ?

A

No.
IP address is always allocated to the POD, once it gets scheduled. Hence, we cannot share same before it’s scheduling.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the roles of a Service in Kubernetes ?

A
  1. Accept the request from external user and pass same to one of POD
  2. Load balance the request
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How a Service knows to which POD it needs to pass the request ?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Does IP address of a service keeps changing ?

A

No, it remains fixed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

On which Networking layer, does Service object works ?

A

Layer 4 (TCP/UDP over IP)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How a frontend POD can communicate with Backend POD ?

A

The Frontend POD can call the IP address of Service which abstracts the accessiblity of Backend PODs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the different types of Services available in Kubernetes ?

A
  1. ClusterIP service
  2. NodePort Service
  3. LoadBalancer Service
  4. ExternalName service
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Can we access the “clusterIP” service from outside the K8 cluster ?

A

No.
ClusterIP service can only be accessed within the K8 cluster.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What’s a clusterIP service ?

A

ClusterIP services is a K8 service which exposes the PODs within the cluster IPs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How a POD belongs to one service can access another POD belongs to another service ?

A

Using “Cluster IP” service.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What’s a Node Port Service ?

A

NodePort Service is a K8 Service which exposes the PODs on Node’s IP address at a static port.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Can we access a POD using NodePort service ?

A

Yes.
It provides access to POD via Node’ IP and static port

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Can a POD be able to access another POD using NodePort Service ?

A

No.
For accessing another service within the Cluster, Cluster IP service is needed.

17
Q

What’s a LoadBalancer Service ?

A

LoadBalancer Service is a service which exposes the PODs on an external Load Balancer.

18
Q

Do we need NodePort Service and Cluster IP service after creation of LoadBalancer Service ?

A

Yes.
During creation of LoadBalancer Service, NodePort Service and ClusterIP services gets automatically created.

19
Q

What’s an externalName Service ?

A

ExternalName service is the K8 service which “abstracts” any external service outside the cluster.

20
Q

How to perform port-forward on a POD using kubectl ?

A

> > > kubectl port-forward pod/my-nginx 8080:80

21
Q

How to perform port-forward on a deployment using kubectl ?

A

> > > kubectl port-forward deployment/my-nginx 8080

22
Q

How to perform port-forward on a service using kubectl ?

A

> > > kubectl port-forward service/my-nginx 8080

23
Q

Create the Service manifest template ?

A

apiVersion: apps/v1
kind: Service
metaData:
spec:
type:
selector:
ports

24
Q

What are the different types of the service we can provide in “service manifest”

A
  1. ClusterIP
  2. NodePort
  3. LoadBalancer
25
Q

What are the different types of port we can provide in service manifest ?

A
  1. Target Port
  2. Service Port
26
Q

Create manifest for Cluster IP service object ?

A

apiVersion: v1
kind: Service
metadata:
name: nginx-clusterIP
spec:
type: ClusterIP
selector:
app: my-nginx
ports:
- port: 8080
targetPort: 80

27
Q

Create manifest for NodePort Service Object ?

A

apiVersion: v1
kind: Service
metadata:
name: nginx-nodeport
spec:
type: NodePort
selector:
app: my-nginx
ports:
- port: 80
targetPort: 80
nodePort: 31000

28
Q

Create manifest for LoadBalancer Service Object ?

A

apiVersion: 1
kind: Service
metadata:
name: nginx-loadbalancer
spec:
type: LoadBalancer
selector:
app: my-nginx
ports:
- name: “80”
port: 80
targetPort: 80