Skip to content

A load balancer application can be developed in minikube and with some tricks. Good for quick quick testing, Demo etc purposes as no costs are incurred (no CSP load balancer is created.)

Notifications You must be signed in to change notification settings

somrajroy/KubernetesMinikubeLB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 

Repository files navigation

Kubernetes-Minikube-Load Balancer

A load balancer application can be developed & tested in minikube and with some tricks & no extra costs.

Steps to be followed

  • Clone the repository and navigate to lab-04 folder in Powershell/CLI
  • Command to check clusters in minikube
    $ minikube profile list
  • Switch to minikube context
    $ kubectl config use-context minikube
  • Create the Deployment resources in k8s-deployments folder
    $ kubectl apply -f ./k8s-deployments/
  • Please list the existing Deployments
    $ kubectl get deployments
  • Check pods
    $ kubectl get pods
  • The worker Pod will fail because there is still no connection between the pods
    image
  • Create the services
    $ kubectl apply -f ./k8s-services/
  • Get the services and you will notice that there is no "External IP" for LoadBalancer is pending because minikube is local. For a CSP there will be an external IP assigned which can be accessed from Internet
    image
  • Check the pods now and the worker pod will be running with restarts. If it is not running the create then delete the deployment and create the worker deployment once again. The YAML file of worker deployment is in folder "k8s-deployments"
    $ kubectl get pods
    image
  • Now the tricky part. Each LoadBalaner service creates a NodePort service. We can find out by the below command. If K8s is running in a cluster which does not support LoadBalancer type service, The Loadbalancer won't be provisioned there and it will continue to treat itself like a NodePort service.
    $ minikube service
  • Run the vote service and it will open in new window and would display the NodePort URL. Give your vote
  • On cloud providers that support load balancers, an external IP address would be provisioned to access the Service. On minikube, the LoadBalancer type makes the Service accessible through the minikube service command.
    $ minikube service vote
    image
  • Access the "result" service and check the results (it will be automatically opened in new browser):
    $ minikube service result
    image
  • Delete Services and deployments
    $ kubectl delete -f ./k8s-services/
    $ kubectl delete -f ./k8s-deployments/
  • Clean everything
    $ kubectl delete all --all

    Kubernetes Loadbalancer service

image
image

About

A load balancer application can be developed in minikube and with some tricks. Good for quick quick testing, Demo etc purposes as no costs are incurred (no CSP load balancer is created.)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published