Skip to content

Commit 85c492f

Browse files
committed
更新ingress文档
1 parent 6e925d6 commit 85c492f

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

docs/guide/ingress.md

+64
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,69 @@ spec:
9393
```
9494
这样在集群外部可以使用 `curl -H Host:traefik-ui.test.com 192.168.1.1:23456` 尝试访问WEB管理页面,返回 `<a href="/dashboard/">Found</a>.`说明 traefik-ui的ingress配置生效了。
9595

96+
### [可选] 部署`ingress-service`的代理
97+
98+
在客户端主机上可以通过修改本机 `hosts` 文件,如上例子,增加两条记录:
99+
100+
``` text
101+
192.168.1.1 hello.test.com
102+
192.168.1.1 traefik-ui.test.com
103+
```
104+
打开浏览器输入域名 `http://hello.test.com:23456``http://traefik-ui.test.com:23456` 就可以访问k8s的应用服务了。
105+
106+
当然如果你的环境中有类似 nginx/haproxy 等代理,可以做代理转发以去掉 `23456`这个端口,这里以 haproxy演示下。
107+
108+
如果你的集群根据本项目部署了高可用方案,那么可以利用`LB` 节点haproxy 来做,当然如果生产环境K8S应用已经部署非常多,建议还是使用独立的 `nginx/haproxy`集群
109+
110+
在 LB 主备节点,修改 `/etc/haproxy/haproxy.cfg`类似如下:
111+
112+
``` bash
113+
global
114+
log /dev/log local0
115+
log /dev/log local1 notice
116+
chroot /var/lib/haproxy
117+
stats socket /run/haproxy/admin.sock mode 660 level admin
118+
stats timeout 30s
119+
user haproxy
120+
group haproxy
121+
daemon
122+
nbproc 1
123+
124+
defaults
125+
log global
126+
timeout connect 5000
127+
timeout client 50000
128+
timeout server 50000
129+
130+
listen kube-master
131+
bind 0.0.0.0:8443
132+
mode tcp
133+
option tcplog
134+
balance source
135+
# 根据实际kube-master 节点数量增减如下endpoints
136+
server s1 192.168.1.1:6443 check inter 10000 fall 2 rise 2 weight 1
137+
server s2 192.168.1.2:6443 check inter 10000 fall 2 rise 2 weight 1
138+
139+
listen kube-node
140+
# 先确认 LB节点80端口可用
141+
bind 0.0.0.0:80
142+
mode tcp
143+
option tcplog
144+
balance source
145+
# 根据实际kube-node 节点数量增减如下endpoints
146+
server s1 192.168.1.1:23456 check inter 10000 fall 2 rise 2 weight 1
147+
server s2 192.168.1.2:23456 check inter 10000 fall 2 rise 2 weight 1
148+
server s3 192.168.1.3:23456 check inter 10000 fall 2 rise 2 weight 1
149+
```
150+
修改保存后,重启haproxy服务;
151+
152+
这样我们就可以访问集群`master-VIP``80`端口,由haproxy代理转发到实际的node节点和nodePort端口上了。这时可以修改客户端本机 `hosts`文件如下:(假定 master-VIP=192.168.1.10)
153+
154+
``` text
155+
192.168.1.10 hello.test.com
156+
192.168.1.10 traefik-ui.test.com
157+
```
158+
打开浏览器输入域名 `http://hello.test.com``http://traefik-ui.test.com`可以正常访问。
159+
96160

97161
[前一篇](heapster.md) -- [目录](index.md) -- [后一篇](efk.md)

0 commit comments

Comments
 (0)