Ingress
Service一般情况下只作用内部Pod的代理调度,如果只指定一个NodeIP,随着业务量增大,这个Node压力就会很大,
这时可能会在前端加一个代理,代理几个Node。在应用小的情况下,这种架构还能接受。但如果有大量应用的话,我们
就需要管理大量的NodePort,这时就需要Ingress来解决
Ingress代理并不是Pod的service,而是Pod。Ingress提供外部访问集群的入口,将外部的HTTP或者HTTPS轻轻转发到
集群内service上,流量规制在Ingress资源上定义
Ingress controller类型,其中Nginx、Traefik为常用类型
- HAProxy Ingress Controller
- Nginx Ingress Controller
- Tracefik Ingress Controller
- Kong Ingress Controller
定义一个简单的Ingres
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: ingress-simple-demo
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /joker
backend:
serviceName: nginx
servicePord: 80
Ingress更新
如果想更改正在工作的Ingress,比如新增一个HOST,可以使用kubectl edit ingress my-ingress进行更新,在保存退出
后会触发Ingress Controller重新配置LB
实例: kubectl edit ingress ingress-simple-demo
spec:
rules:
- http:
paths:
- backend:
serviceName: nginx-service
servicePort: 8000
path: /joker
- host: bar.baz.com
http:
paths:
- backend:
serviceName: nginx
servicePort: 80
path: /foo
status:
loadBalancer: {}
标签:Ingress,ingress,nginx,Controller,path,K8S,backend
From: https://www.cnblogs.com/codechange/p/17853345.html