Traffic Mirroring
- You need to enable KubeSphere Service Mesh.
- You need to create a workspace, a project and an account (). The account must be invited to the project with the role of
operator
. For more information, see . - You need to enable Application Governance and have an available app so that you can mirror the traffic of it. The sample app used in this tutorial is Bookinfo. For more information, see Deploy Bookinfo and Manage Traffic.
Log in to KubeSphere as
project-regular
. Under Categories, click Create Job on the right of Traffic Mirroring.Set a name for it and click Next.
Select your app from the drop-down list and the service of which you want to mirror the traffic. If you also use the sample app Bookinfo, select reviews and click Next.
On the Grayscale Release Version page, add another version of it (e.g.
v2
) as shown in the image below and click Next:The image version is
v2
in the screenshot.Click Create in the final step.
You can see the traffic is being mirrored to
v2
with real-time traffic displaying in the line chart.The new Deployment is created as well.
You can directly get the virtual service to view
mirror
andweight
by executing the following command:Note
- When you execute the command above, replace
demo-project
with your own project (i.e. namespace) name. - If you want to execute the command from the web kubectl on the KubeSphere console, you need to use the account
admin
.
- When you execute the command above, replace
Expected output:
...
hosts:
- reviews
http:
- destination:
host: reviews
port:
number: 9080
subset: v1
weight: 100
host: reviews
port:
number: 9080
subset: v2
This route rule sends 100% of the traffic to
v1
. The last stanza specifies that you want to mirror to the servicereviews v2
. 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
.Note
These requests are mirrored as “fire and forget”, which means that the responses are discarded. You can specify the field to mirror a fraction of the traffic, instead of mirroring all requests. If this field is absent, for compatibility with older versions, all traffic will be mirrored. For more information, see .
You can remove the traffic mirroring job by clicking Job offline, which does not affect the current app version.