《OpenShift 4.x HOL教程汇总》
说明:本文已经在OpenShift 4.10环境中验证
OpenShift 内置路由功能以实现 Kubernetes 的 Ingress。针对路由可以设置访问白名单,以拦截来自不明网络的非法请求。
- 在 OpenShift 上根据下图部署 https://github.com/liuxiaoyu-git/php-helloworld 应用。
- 通过部署好的应用 Route 访问,确认应用显示下图。其中下图的 “ 209.132.188.14” 是访问 Route 的客户 IP 地址。
- 在下图中的“路由”区域找到 helloworld,然后点击进入。
- 在 路由详情 中点击右侧的 “操作”,然后再点击 “编辑注释”。
- 在弹出窗口中增加一个新的注释,设置名称为 “haproxy.router.openshift.io/ip_whitelist”,值为 “209.132.188.0/24”。这样就允许“209.132.188.0” 网段所有地址访问 “helloworld” 应用。
- 刷新 helloworld 页面,确认应用还可正常访问。
- 修改 helloworld 路由的注释,将白名单的地址改为 “209.132.189.0/24”,。
- 刷新 helloworld 页面,确认应用无法正常访问。
- 还可根据以下对 helloworld 路由设置其他注释,以预防 DDos。
metadata:
annotations:
haproxy.router.openshift.io/ip_whitelist: 209.132.188.0/24
haproxy.router.openshift.io/pod-concurrent-connections: 10
haproxy.router.openshift.io/rate-limit-connections: true
haproxy.router.openshift.io/rate-limit-connections.rate-http: 1