Azure Kubernetes - AKS - K8s 版本 - 1.20.9。
尝试使用内部 LB 设置多个 nginx 入口。
具有入口类的入口控制器 -
helm install test1 ingress-nginx/ingress-nginx \
--set controller.replicaCount=1 \
--set controller.nodeSelector."beta\.kubernetes\.io/os"=linux \
--set defaultBackend.nodeSelector."beta\.kubernetes\.io/os"=linux \
--set controller.ingressClassResource.name=test1 \
--set controller.service.annotations."service\.beta\.kubernetes\.io/azure-load-balancer-internal"=true
安装 LB 服务和 Ingress Class 后创建。
服务-
test1-ingress-nginx-controller LoadBalancer 10.0.52.125 10.240.0.4 80:32472/TCP,443:30586/TCP 4h9m
test1-ingress-nginx-controller-admission ClusterIP 10.0.32.211 <none> 443/TCP 4h9m
入口类-
NAME CONTROLLER PARAMETERS AGE
test1 k8s.io/test1 <none> 155m
入口文件
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: hello-world-ingress-my-external
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: test1
rules:
- host: test1.com
http:
paths:
- backend:
serviceName: aks-helloworld
servicePort: 80
path: /app(.*)
- backend:
serviceName: ingress-demo
servicePort: 80
path: /hello-world-two(/|$)(.*)
Ingress-2
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: hello-world-ingress-my-external
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: test2
rules:
- host: test2.com
http:
paths:
- backend:
serviceName: helloworld
servicePort: 80
path: /app(.*)
- backend:
serviceName: demo
servicePort: 80
path: /hello(/|$)(.*)
创建入口后仅显示第一个 ip
NAME CLASS HOSTS ADDRESS PORTS AGE
external-ingress test1 test4.com 10.0.240.6 80 67m
hello-world-ingress-my-external test2 test3.com 10.0.240.6 80 104
流量未根据 IngressClass 进行更新。请帮忙,为什么所有入口都使用相同的 IP?如何根据 ingressclass 提供流量?
提前致谢。
更新- 更新后,我能够管理多个入口的流量
--set controller.ingressClass=test \
--set controller.ingressClassResource.name=test --set controller.ingressClassResource.controllerValue="k8s.io/test-controller"
最终掌舵命令
helm install test1 ingress-nginx/ingress-nginx --set controller.ingressClass=test1 --set controller.ingressClassResource.name=test1 --set controller.ingressClassResource.controllerValue="k8s.io/test1-controller" \
--set controller.service.annotations."service\.beta\.kubernetes\.io/azure-load-balancer-internal"=true
Ingress 仍未显示 IP
NAME CLASS HOSTS ADDRESS PORTS AGE
external-ingress test1 test3.com 80 19m
hello-world-ingress-my-external test2 test1.com 80 33m