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:
kubectl create deployment gen-deploy --image=pbitty/hello-from:latest --port=80 --replicas=31.2 Checking the deployment and the replicated pods created:
kubectl get deploy,po --show-labels1.3 Exposing the service object with the type=NodePort to be accessible from the external world:
kubectl expose deployment gen-deploy --type=NodePort1.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
kubectl get deploy,po,svc,ep -l app=gen-deploy --show-labels1.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
minikube service gen-deploy1.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.
minikube ssh
curl http:192.168.49.2:31747Hello from gen-deploy
Hello from gen-deploy
Hello from gen-deploy






