minikube // setup node ports for balancing

requirements

emulate multiple nodes with minikube

#minikube delete --all
minikube start --driver=docker --nodes 2
docker ps
minikube status
kubectl get nodes -o wide

minikube addons enable metrics-server

KISS NodePort + replicas

kubectl create deployment web --image=gcr.io/google-samples/hello-app:1.0 --replicas=3
kubectl get deploy -o wide
kubectl get pods -o wide

==> here one pod on node1 and two pods on node2

kubectl expose deployment web --type=NodePort --port=8080
kubectl get svc -o wide

and check

curl http://192.168.49.2:30329
curl http://192.168.49.3:30329

==> goes to 3 different hostnames/pods whatever node you are talking to

note it will always go to the same pod if you use a web browser… (thanks to the keepalive feature that is enabled by default)

Additional notes

NodePort is already balancing across the cluster, not sure what this is useful for

#kubectl expose deployment web --type=LoadBalancer --port=8080

resources

https://minikube.sigs.k8s.io/docs/start/

https://kubernetes.io/docs/tutorials/hello-minikube/

https://www.digitalocean.com/community/tutorials/how-to-use-minikube-for-local-kubernetes-development-and-testing

https://minikube.sigs.k8s.io/docs/tutorials/multi_node/

multi-node

https://minikube.sigs.k8s.io/docs/tutorials/multi_node/

https://pet2cattle.com/2021/01/multinode-minikube


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Copyright © 2023 Pierre-Philipp Braun