Skip to content

genquiky/K8S-Load-Balancer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 

Repository files navigation

image

Part II: Service and Load Balancer

In this practical exercise I have created a deployment with 3 replicas, exposing the pods to the internet through the service object and demonstrating how the load balancer distributes traffic to each endpoint.

Steps:

1.1 Creating a deployment gen-deploy with 3 replicas and adding the text hello from:deploy in the image:

image

 kubectl create deployment gen-deploy --image=pbitty/hello-from:latest --port=80 --replicas=3


1.2 Checking the deployment and the replicated pods created:

image

kubectl get deploy,po --show-labels


1.3 Exposing the service object with the type=NodePort to be accessible from the external world:

image

kubectl expose deployment gen-deploy --type=NodePort


1.4 Listing the deploy, pods, service and endpoints IPs with the label gen-deploy:

Assigned endpoints IPs:
10.244.0.4:80
10.244.1.10:80
10.244.1.9:80

image

kubectl get deploy,po,svc,ep -l app=gen-deploy --show-labels


1.5 Checking the IP assigned to the service exposed to the internet, from the cluster using minikube.
This is a unique external IP access to the application 192.168.49.2:31747

image

   minikube service gen-deploy


1.6 Accessing the service in the cluster using the URL assigned by Kubernetes from the outside:
Here I can confirm access to the application and that the load balancer distributes traffic to each replicas.

image

   minikube ssh
   curl http:192.168.49.2:31747

Hello from gen-deploy
Hello from gen-deploy
Hello from gen-deploy

About

Kubernetes Part II: Exposing the Service for access to the application from outside and Load Balancing traffic.

Topics

Resources

Stars

Watchers

Forks

Contributors