Flow:
nginx1 = front-end
nginx2 = backend
nginx2a = backend (mirror)
=============> [MeshService: nginx2]
[MeshService: nginx1]
====MIRROR===> [MeshService: nginx2a]
With these components:
$ k get hostnamegenerators.kuma.io -n kuma-system
NAME AGE
synced-universal-mesh-service 3h41m
$ k get dataplanes.kuma.io -n mesh1
NAME KUMA.IO/SERVICE KUMA.IO/SERVICE
nginx1-6f68799dc5-7phww nginx1_mesh1_svc_80
nginx2-78c464c574-pqmk7 nginx2_mesh1_svc_80
nginx2a-6bc94b8f89-dlcg7 nginx2a_mesh1_svc_80
$ k get meshservices.kuma.io -n mesh1
NAME HOSTNAME
nginx1 nginx1.svc.mesh.local
nginx2 nginx2.svc.mesh.local
nginx2a nginx2a.svc.mesh.local
Finally, apply this yaml:
apiVersion: kuma.io/v1alpha1
kind: MeshHTTPRoute
metadata:
name: mirror-nginx
labels:
kuma.io/mesh: default
spec:
targetRef:
kind: MeshSubset
tags:
kuma.io/service: nginx1_mesh1_svc_80
to:
- targetRef:
kind: MeshService
name: nginx2
rules:
- matches:
- path:
type: PathPrefix
value: /
default:
filters:
- type: RequestMirror
requestMirror:
percentage: 100
backendRef:
kind: MeshServiceSubset
name: nginx2a_mesh1_svc_80
tags:
kuma.io/service: nginx2a_mesh1_svc_80
All traffic from nginx1 to nginx2 will also be forwarded to nginx2a.
POC:
That is all
Update1:
For Kuma 2.7.x LTS is more simple
apiVersion: kuma.io/v1alpha1
kind: MeshHTTPRoute
metadata:
name: http-route-1
namespace: kuma-system
labels:
kuma.io/mesh: default
spec:
targetRef:
kind: MeshSubset
proxyTypes:
- Sidecar
tags:
kuma.io/service: nginx_mesh1_svc_80
to:
- rules:
- default:
backendRefs:
- kind: MeshService
name: echo_mesh1_svc_80
weight: 1
filters:
- requestMirror:
backendRef:
kind: MeshServiceSubset
name: echo2_mesh2_svc_80
weight: 1
percentage: 100
type: RequestMirror
matches:
- path:
type: PathPrefix
value: /
targetRef:
kind: MeshService
name: echo_mesh1_svc_80