Skip to content

Latest commit

 

History

History
54 lines (42 loc) · 1.96 KB

loadballance_ingress_nodeport.md

File metadata and controls

54 lines (42 loc) · 1.96 KB

配置负载转发 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

# 编辑 roles/ex-lb/defaults/main.yml,配置如下变量
INGRESS_NODEPORT_LB: "yes"
INGRESS_TLS_NODEPORT_LB: "yes"

2.重新配置启动LB节点服务

$ ezctl setup ${集群名} ex-lb 

3.验证 ex_lb 节点的 haproxy 服务配置 /etc/haproxy/haproxy.cfg 包含如下配置

... 前文省略
listen kube_master
        bind 0.0.0.0:8443
        mode tcp
        option tcplog
        balance roundrobin
        server 192.168.1.1 192.168.1.1:6443 check inter 2000 fall 2 rise 2 weight 1
        server 192.168.1.2 192.168.1.2:6443 check inter 2000 fall 2 rise 2 weight 1

listen ingress-node
        bind 0.0.0.0:80
        mode tcp
        option tcplog
        balance roundrobin
        server 192.168.1.3 192.168.1.3:23456 check inter 2000 fall 2 rise 2 weight 1
        server 192.168.1.4 192.168.1.4:23456 check inter 2000 fall 2 rise 2 weight 1

listen ingress-node-tls
        bind 0.0.0.0:443
        mode tcp
        option tcplog
        balance roundrobin
        server 192.168.1.3 192.168.1.3:23457 check inter 2000 fall 2 rise 2 weight 1
        server 192.168.1.4 192.168.1.4:23457 check inter 2000 fall 2 rise 2 weight 1

验证成功后,我们可以方便的去做配置ingress配置https ingress实验了。