istio - 如何在 istio 上 Knative 获取客户端 ip
问题描述
我在 knative 中使用 istio。由于客户端 ip 没有来,我激活了反向代理。我添加了特使过滤器。但是我在 knative 上的服务中收到“上游连接错误或断开/重置标题。重置原因:连接终止”错误。如果它不是 knative 服务,我可以访问它。
虚拟服务
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: test-entry-route
namespace: default
spec:
gateways:
- knative-serving/knative-ingress-gateway
hosts:
- "test.net"
http:
- match:
- uri:
prefix: /test/ #working
rewrite:
uri: /
route:
- destination:
host: user-api.test.svc.cluster.local
port:
number: 80
- match:
- uri:
prefix: /user/ #not working
route:
- destination:
host: istio-ingressgateway.istio-system.svc.cluster.local
port:
number: 80
weight: 100
rewrite:
authority: user-api.poker-test.k8s.test.net
uri: /
特使过滤器
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: proxy-protocol
namespace: istio-system
spec:
configPatches:
- applyTo: LISTENER
patch:
operation: MERGE
value:
listener_filters:
- name: envoy.listener.proxy_protocol
- name: envoy.listener.tls_inspector
workloadSelector:
labels:
istio: ingressgateway
服务负载均衡器
annotations:
service.beta.kubernetes.io/do-loadbalancer-enable-proxy-protocol: 'true'
externalTrafficPolicy: Local
解决方案
推荐阅读
- image-stitching - 在拼接之前去模糊图像,这行得通吗?
- javascript - 如何使用动物数据库中的索引搜索部分匹配
- javascript - 从上下文渲染可变样式的组件
- mysql - InnoDB:文件 rem0rec.cc 第 586 行中线程 139982489777920 中的断言失败
- javascript - 当 v-model 值更改时,自定义 Vue 选择组件不更新所选选项
- c# - 无法从 'double' 转换为 'System.ReadOnlySpan
' 尝试使用 `TryParse` 时出错 - angular - Json文件未在html表中显示数据
- javascript - 继续从源“(本地服务器)”访问“(api url)”处的 XMLHttpRequest 已被 CORS 策略阻止
- mysql - 如何在nodejs中使用钩子/续集更新数据库
- pandas - 读取大文本文件