minikube and ingress

lessons learned

three nodes

#minikube delete --all
minikube start --driver=docker --nodes 3
minikube addons enable metrics-server

and most importantly

minikube addons enable ingress

three replicas

kubectl create deployment web --image=gcr.io/google-samples/hello-app:1.0 --replicas=3
kubectl expose deployment web --type=NodePort --port=8080
kubectl get service web -o wide
minikube service web --url
curl http://192.168.49.2:32577
curl http://192.168.49.2:32577
curl http://192.168.49.2:32577

curl http://192.168.49.3:32577
curl http://192.168.49.3:32577
curl http://192.168.49.3:32577

curl http://192.168.49.4:32577
curl http://192.168.49.4:32577
curl http://192.168.49.4:32577

enable ingress

minikube addons enable ingress
kubectl get pods -n ingress-nginx

vi example-ingress.yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
    - host: hello-world.info
      http:
    paths:
      - path: /
        pathType: Prefix
        backend:
          service:
        name: web
        port:
          number: 8080

kubectl apply -f example-ingress.yaml

kubectl get svc
kubectl get ingress

check

curl --resolve hello-world.info:80:192.168.49.2 -i http://hello-world.info # OK
curl --resolve hello-world.info:80:192.168.49.3 -i http://hello-world.info # NOK
curl --resolve hello-world.info:80:192.168.49.4 -i http://hello-world.info # NOK

resources

https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types

https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/

https://kubernetes.io/docs/concepts/services-networking/ingress/

https://k8s-docs.netlify.app/en/docs/tasks/access-application-cluster/ingress-minikube/ ==> lives into kube-system ns

https://nginx.com/blog/guide-to-choosing-ingress-controller-part-4-nginx-ingress-controller-options/ ==> ingress-nginx vs nginx-ingress

alternatives

https://www.cncf.io/blog/2021/10/20/a-guide-to-choosing-an-ingress-controller-part-1-identify-your-requirements/

moar

https://stackoverflow.com/questions/68449554/ingress-rule-using-host

https://stackoverflow.com/questions/63474636/ingress-with-and-without-host


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