我正在尝试使用 traefik 获取我的 Kubernetes pod 的真实源 IP 地址。我正在使用启用了代理协议的数字海洋负载均衡器。我还配置了我的 K8s 服务 yaml 以将外部流量策略设置为本地。
从我在 K8s 中的配置映射中提取 Traefik Ingress。我已经编辑了我的实际 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
这是部署文件服务 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
任何帮助总是受到赞赏。