日本免费全黄少妇一区二区三区-高清无码一区二区三区四区-欧美中文字幕日韩在线观看-国产福利诱惑在线网站-国产中文字幕一区在线-亚洲欧美精品日韩一区-久久国产精品国产精品国产-国产精久久久久久一区二区三区-欧美亚洲国产精品久久久久

Router vs Route詳解 route和router的區(qū)別是什么( 三 )


因此,OpenShift 的路由器功能需要能對這三部分進行管理和控制 。
2.3 全局配置管理
要指定或修改 HAProxy 的全局配置,OpenShift 有提供兩種方式:
(1)第一種是使用 oc adm router 命令在創(chuàng)建 router 時候指定各種參數,比如 --max-connections 用于設置最大連接數 。比如:
oc adm router --max-connections=200000 --ports='81:80,444:443' router3
創(chuàng)建出來的HAProxy 的 maxconn 將是 20000,router3 這個服務對外暴露出來的端口是 81 和 444,但是 HAProxy pod 的端口依然是 80 和 443.
(2)通過設置 dc/ 的環(huán)境變量來設置 router 的全局配置 。
在官方文檔 https://docs.openshift.com/container-platform/3.4/architecture/core_concepts/routes.html#haproxy-template-router 中有完整的環(huán)境變量列表 。比如運行以下命令后,
oc set env dc/router3 ROUTER_SERVICE_HTTPS_PORT=444 ROUTER_SERVICE_HTTP_PORT=81 STATS_PORT=1937
router3 會重新部署,新部署的HAProxy 的 https 監(jiān)聽端口是 444,http 監(jiān)聽端口是 80,統(tǒng)計端口是 1937.
2.4 OpenShift passthrough 類型的 route 與 HAProxy backend
(1)通過OpenShift Console 或者 oc 命令創(chuàng)建一條 route,它將 sit 項目的 jenkins 服務暴露到域名 sitjenkins.com.cn:
在界面上創(chuàng)建 route:

Router vs Route詳解 route和router的區(qū)別是什么



Router vs Route詳解 route和router的區(qū)別是什么


結果:
Name: sitjenkins.com.cnNamespace: sitLabels: app=jenkins-ephemeral template=jenkins-ephemeral-templateAnnotations: Requested Host: sitjenkins.com.cnPath: TLS Termination: passthroughEndpoint Port: webService: jenkinsWeight: 100 (100%)Endpoints: 10.128.2.15:8080, 10.131.0.10:8080
【Router vs Route詳解 route和router的區(qū)別是什么】這里,service name 起了一個中介作用,把 route 和服務的端點(也就是pod)連接了起來 。
(2)router 服務的兩個 pod 中的 HAProxy 進程的配置文件中多了一個backend:
# Secure backend, pass throughbackend be_tcp:sit:sitjenkins.com.cn balance source hash-type consistent timeout check 5000ms} server pod:jenkins-1-bqhfj:jenkins:10.128.2.15:8080 10.128.2.15:8080 weight 256 check inter 5000ms server pod:jenkins-1-h2fff:jenkins:10.131.0.10:8080 10.131.0.10:8080 weight 256 check inter 5000ms
其中,這些后端 server 其實就是 pod,它們是 openshift 通過步驟(1)中的 service name 找到的 。balance 是負載均衡策略,后文會解釋 。
(3)文件
/var/lib/haproxy/conf/os_sni_passthrough.map 中多了一條記錄
sh-4.2$ cat /var/lib/haproxy/conf/os_sni_passthrough.map^sitjenkins\.com\.cn(:[0-9]+)?(/.*)?$ 1
(4)文件
/var/lib/haproxy/conf/os_tcp_be.map 中多了一條記錄
sh-4.2$ cat /var/lib/haproxy/conf/os_tcp_be.map^sitjenkins\.com\.cn(:[0-9]+)?(/.*)?$ be_tcp:sit:sitjenkins.com.cn
(5)HAProxy 根據上面的 map 文件為該條 route 選擇第(2)步中增加的 backend的邏輯如下
frontend public_ssl #解釋:前端協(xié)議 https, bind :443 ##前端端口 443 tcp-request inspect-delay 5s tcp-request content accept if { req_ssl_hello_type 1 } # if the connection is SNI and the route is a passthrough don't use the termination backend, just use the tcp backend # for the SNI case, we also need to compare it in case-insensitive mode (by converting it to lowercase) as RFC 4343 says acl sni req.ssl_sni -m found ##檢查 https request 支持 sni acl sni_passthrough req.ssl_sni,lower,map_reg(/var/lib/haproxy/conf/os_sni_passthrough.map) -m found ##檢查通過 sni 傳來的 hostname 在 os_sni_patthrough.map 文件中 use_backend %[req.ssl_sni,lower,map_reg(/var/lib/haproxy/conf/os_tcp_be.map)] if sni sni_passthrough ##從 oc_tcp_be.map 中根據 sni hostname 獲取 backend name # if the route is SNI and NOT passthrough enter the termination flow use_backend be_sni if sni # non SNI requests should enter a default termination backend rather than the custom cert SNI backend since it # will not be able to match a cert to an SNI host default_backend be_no_sni

推薦閱讀