Before you want to try this on your local, here are requirements
- Directly download Virtualbox and install, or use homebrew
brew install --cask virtualbox
- Vagrant
brew install --cask vagrant
- (Optional) Vagrant Manager
brew install --cask vagrant-manager
Follow Create a HA Kubernetes cluster with kubeadm, keepalived, and haproxy by Ansible to set up a HA Kubernetes cluster.
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.1.1/deploy/static/provider/baremetal/deploy.yaml
kubectl -n ingress-nginx get pods
Patch ingress-nginx-controller
service to set nodePort
to 30100
and 30101
kubectl -n ingress-nginx patch svc ingress-nginx-controller --patch \
'{"spec": { "type": "NodePort", "ports": [ { "port": 80, "nodePort": 30100 }, { "port": 443, "nodePort": 30101 } ] } }'
kubectl -n ingress-nginx get svc
Patch ingress-nginx-controller
configmap to for use-proxy-protocol
kubectl -n ingress-nginx patch configmap ingress-nginx-controller --patch-file patch-configmap.yaml
See task Configure haproxy
in lb_playbook.yml
Source: https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/
Deploy
kubectl apply -f my-nginx-deploy.yaml
kubectl get pods -l run=my-nginx
Expose service
kubectl apply -f my-nginx-svc.yaml
kubectl get svc my-nginx
nip.io allows us to map any IP Address to a hostname using the defined formats, then we do not need to edit etc/hosts
file
kubectl apply -f my-nginx-ingress.yaml
Open on browser http://172.16.0.16.nip.io, or
open http://172.16.0.16.nip.io