Debug School

ASHISH KUMAR AWASTHI
ASHISH KUMAR AWASTHI

Posted on

Assignment-DAY3

What is service?
Services are endpoint which is used to create load balancing for pods. Different label used in load balancing .This label must match to the pod label as well load balance label in order to get proper load balancing.

Why we need it?
Services usually create load balancing at multiple Laval ie Pod level (front and beckend) or node level.
Three type of service available:
1) ClusterIP
2) Node Port
3) Load balancer

How it works?
First load balancer at pod level exposed the front end Pod port which is known as Cluster IP load balancing.
Node port usually load balancer at Node port, which exposed the front end Pod level port to externally at Node level.
It may needed to create load balancer externally at cloud end, to access container from outside world. This may be done with the help of DNS.

Command for it
Create two pod:--
vi pod5.yaml
vi pod6.yaml
kubectl apply -f pod5.yaml
kubectl apply -f pod6.yaml

Create ClusterIP node balancer:-

kubectl create service clusterip ash-cs --tcp=5678:80
kubectl describe svc ash-cs
kubectl get pods --show-labels
!!--Modify the lable at Service ash-cs that must match to the pods.
kubectl edit svc ash-cs

!!--Create Node Port load Balancer:--
kubectl create service nodeport ash-ns --tcp=5678:80
kubectl get pods --show-labels

!!--Modify the Label as per the pod lable:--
kubectl edit svc ash-ns

kubectl describe svc ash-ns
kubectl describe svc ash-cs

Check the access using mapped port and IP of Cluster and Node IP
curl http://10.111.228.235:5678
curl http://10.100.232.215:5678
watch curl http://10.111.228.235:5678

Top comments (0)