如何在 Kubernetes 上复制一些流量并将其转移到 Service 进行调查
How to replicate some traffic on Kubernetes and divert it to the Service for investigation
我正在使用 istio,我知道我可以在虚拟服务中定义权重并将流量转移到不同的服务。
我的问题是:如何放大部分流量并将放大后的流量导向验证服务?这种放大的流量不会返回到原始源,而是会在集群内关闭。换句话说,它不会打扰用户。
我什至不确定是否有提供这种机制的生态系统、功能或应用程序。我什至不知道是否有生态系统或应用程序提供这种机制,我也不知道它叫什么,所以我很难找到它。
谢谢。
OP 在评论中自己找到了灵魂,因此是 CW。
在这种情况下,最好的解决方案是使用 Istio Mirroring - 也称为阴影。
When traffic gets mirrored, the requests are sent to the mirrored service with their Host/Authority headers appended with -shadow
. For example, cluster-1
becomes cluster-1-shadow
.
Also, it is important to note that these requests are mirrored as “fire and forget”, which means that the responses are discarded.
要创建镜像规则,您必须使用 mirror
和 mirrorPercentage
字段创建 VirtualService。
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: httpbin
spec:
hosts:
- httpbin
http:
- route:
- destination:
host: httpbin
subset: v1
weight: 100
mirror:
host: httpbin
subset: v2
mirrorPercentage:
value: 100.0
This route rule sends 100% of the traffic to v1. The last stanza specifies that you want to mirror (i.e., also send) 100% of the same traffic to the httpbin:v2 service.
[source]
我正在使用 istio,我知道我可以在虚拟服务中定义权重并将流量转移到不同的服务。
我的问题是:如何放大部分流量并将放大后的流量导向验证服务?这种放大的流量不会返回到原始源,而是会在集群内关闭。换句话说,它不会打扰用户。
我什至不确定是否有提供这种机制的生态系统、功能或应用程序。我什至不知道是否有生态系统或应用程序提供这种机制,我也不知道它叫什么,所以我很难找到它。
谢谢。
OP 在评论中自己找到了灵魂,因此是 CW。
在这种情况下,最好的解决方案是使用 Istio Mirroring - 也称为阴影。
When traffic gets mirrored, the requests are sent to the mirrored service with their Host/Authority headers appended with
-shadow
. For example,cluster-1
becomescluster-1-shadow
.Also, it is important to note that these requests are mirrored as “fire and forget”, which means that the responses are discarded.
要创建镜像规则,您必须使用 mirror
和 mirrorPercentage
字段创建 VirtualService。
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: httpbin
spec:
hosts:
- httpbin
http:
- route:
- destination:
host: httpbin
subset: v1
weight: 100
mirror:
host: httpbin
subset: v2
mirrorPercentage:
value: 100.0
This route rule sends 100% of the traffic to v1. The last stanza specifies that you want to mirror (i.e., also send) 100% of the same traffic to the httpbin:v2 service.
[source]