k8s/StudyNotes/k8s Ingress Service
- Service [ clusterPort, nodePort]
Problem service nodePort > 30k, so need proxy server for port 80, 443 to this port.
On cloud set to LoadBalancer, still nodePort + talks to cloud paltform to configure the LB
- e.g. svc1 p38080, svc2 p38282, need yet another load-balancer
- Ingress - l7 loadbalancer config, path based.
- Ingress controller Nginx, HAPROXY, traefik, GCE(Google), Istio
- Not deployed by default
e.g. Deploy nginx-ingress-controller as Deployment + ConfigMap + Service + ServiceAccount
- Not deployed by default
Ingress Resource
apiVersion: networking.k8s.io/v1 kind: Ingress spec: rules: - host: wear.my-online-store.com http: paths: - path: /wear pathType: Prefix backend: serviceName: wear-service servicePort: 80 - path: /watch pathType: Prefix backend: serviceName: watch-service servicePort: 80
- Ingress controller Nginx, HAPROXY, traefik, GCE(Google), Istio
From 1.20, kubectl create ingress <ingress-name> --rule="host.com/path*=wear-svc:80"
- Different ingress controllers can have annotations to set feature.
e.g. for nginx to strip /path/ when sending to backend service
annotations: nginx.ingress.kubernetes.io/rewrite-target: /
or
annotations: nginx.ingress.kubernetes.io/rewrite-target: /$2 ... spec: rules: - http: paths: - path: /something(/|$)(.*)