Rut*_*net 5 digital-ocean kubernetes real-ip traefik traefik-ingress
我正在尝试使用 traefik 获取 Kubernetes pod 的真实源 IP 地址。我正在使用启用了代理协议的数字海洋负载均衡器。我还配置了 K8s 服务 yaml,将外部流量策略设置为本地。
从我的 K8s 中的 Traefik Ingress configmap 中摘录。我已经编辑了我的实际 IP,但我使用我的负载均衡器 IP 和 Kubernetes 工作节点专用 IP
[entryPoints]
[entryPoints.http]
address = ":80"
compress = true
[entryPoints.http.redirect]
entryPoint = "https"
[entryPoints.https]
address = ":443"
compress = true
[entryPoints.https.tls]
[[entryPoints.https.tls.certificates]]
CertFile = "/ssl/client_co.crt"
KeyFile = "/ssl/tls.key"
[entryPoints.https.proxyProtocol]
trustedIPs = ["Load Balancer IP, Kubernetes Worker Node IPs"]
[entryPoints.https.redirect]
regex = "^https://(?:www\\.)(.*)"
replacement = "https://$1"
permanent = true
Run Code Online (Sandbox Code Playgroud)
这是部署文件服务yaml的一部分
kind: Service
apiVersion: v1
metadata:
name: traefik-ingress-service
annotations:
service.beta.kubernetes.io/do-loadbalancer-enable-proxy-protocol: "true"
namespace: kube-system
spec:
selector:
k8s-app: traefik-ingress-lb
ports:
- protocol: TCP
port: 80
name: web
- protocol: TCP
port: 443
name: https
# - protocol: TCP
# port: 8080
name: admin
type: LoadBalancer
externalTrafficPolicy: Local
Run Code Online (Sandbox Code Playgroud)
任何帮助总是值得赞赏。
| 归档时间: |
|
| 查看次数: |
3542 次 |
| 最近记录: |