配置负载转发 ingress nodeport
向集群外暴露 ingress-controller 本身的服务端口(80/443/8080)一般有以下三种方法:
-
1.部署ingress-controller时使用hostNetwork: true
,这样就可以直接使用上述端口,可能与host已listen端口冲突
-
2.部署ingress-controller时使用LoadBalancer
类型服务,需要集群支持LoadBalancer
-
3.部署ingress-controller时使用nodePort
类型服务,然后在集群外使用 haproxy/f5 等配置 virtual server 集群
本文讲解使用 haproxy 配置 ingress的 VS 集群,前提是配置了自建ex-lb
节点
1.配置 ex-lb 参数开启转发 ingress nodeport
1 2 3 4
| [ex-lb] 10.0.0.10 LB_ROLE=master EX_APISERVER_VIP=10.0.0.250 EX_APISERVER_PORT=8443 10.0.0.20 LB_ROLE=backup EX_APISERVER_VIP=10.0.0.250 EX_APISERVER_PORT=8443
|
如图所示:

1 2 3
| INGRESS_NODEPORT_LB: "yes" INGRESS_TLS_NODEPORT_LB: "yes"
|
2.重新配置启动LB节点服务
1
| $ ansible-playbook /etc/ansible/roles/ex-lb/ex-lb.yml
|
3.验证 ex-lb 节点的 haproxy 服务配置 /etc/haproxy/haproxy.cfg
包含如下配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| ... 前文省略 listen kube-master bind 0.0.0.0:8443 mode tcp option tcplog option dontlognull option dontlog-normal balance roundrobin server 10.0.0.10 10.0.0.10:6443 check inter 5s fall 2 rise 2 weight 1 server 10.0.0.20 10.0.0.20:6443 check inter 5s fall 2 rise 2 weight 1
listen ingress-node bind 0.0.0.0:80 mode tcp option tcplog option dontlognull option dontlog-normal balance roundrobin server 10.0.0.30 10.0.0.30:23456 check inter 5s fall 2 rise 2 weight 1 server 10.0.0.40 10.0.0.40:23456 check inter 5s fall 2 rise 2 weight 1
listen ingress-node-tls bind 0.0.0.0:443 mode tcp option tcplog option dontlognull option dontlog-normal balance roundrobin server 10.0.0.30 10.0.0.30:23457 check inter 5s fall 2 rise 2 weight 1 server 10.0.0.40 10.0.0.40:23457 check inter 5s fall 2 rise 2 weight 1
|
打开网页访问VIP,看下是否验证成功。如图所示:
Traefik

K8S-面板
