Creating A Load Balancer using kubernetes
Install minikube, kubectl on your system.
Minikube is used to create a local K8s cluster. After installing minikube, run the following commands to start a minikube cluster on docker.
- Create a Kubernetes cluster: You need to have a Kubernetes cluster running on Fedora. You can use a tool like kubeadm to create a cluster.
- Create a deployment: You need to create a deployment that defines the pods that will run your application. You can use a YAML file to define the deployment.
- Create a service: You need to create a service that exposes your deployment to the network. You can use a YAML file to define the service. In the YAML file, you can specify the type field as LoadBalancer to create a load balancer service.
- Deploy the service: You can deploy the service using the kubectl create command.
Step 1: minikube start --driver=kvm2
It will perform the following tasks:
- Starting control plane node minikube in cluster minikube
- Pulling base image ...
gcr.io/k8s-minikube/kicbase..
- Preparing Kubernetes v1.28.3 on kvm.
- kubectl is now configured to use "minikube" cluster and "default" namespace by default
Reference: https://minikube.sigs.k8s.io/docs/drivers/kvm2/
Step 2: Deployment of minikube(kubernetes cluster)
kubectl apply -f deployment.yaml
You should get an output similar to this:
service/flask-test-service created
deployment.apps/flask-test-app created
Step 3:
kubectl get po -A
kubectl get po
kubectl get svc
minikube dashboard
On the browser,
You can access your flask application in your local host browser.
minikube service flask-test-service
Reference: https://minikube.sigs.k8s.io/docs/start/ https://minikube.sigs.k8s.io/docs/drivers/kvm2/
Docker Hub