You can configure host redirection to redirect requests destined for a specific service host to a different one.
Prerequisites
Ensure you have deployed the httpbin, sleep, and nginx services as described in Preparation.
Procedure
-
Create a VirtualService that forwards requests destined for the httpbin service to the nginx service.
-
Log on to the ASM console. In the navigation pane on the left, choose .
-
On the Mesh Management page, click the name of the target instance. In the navigation pane on the left, choose , and then click Create.
-
On the Create page, set the namespace to default, the service name to httpbin, and the destination host for the HTTP route to nginx.default.svc.cluster.local. Click Preview to review the YAML content. If the content is correct, click Submit and then click Create.
-
-
Run the following command to verify that the host redirection is working.
kubectl exec -it deploy/sleep -- curl httpbin:8000|grep -o "<title>.*</title>"Expected output:
<title>Welcome to nginx!</title>The response is from the nginx service, which confirms that the request from the sleep container to the httpbin service's root path was successfully redirected to nginx.
ImportantIn Ambient Mesh mode, if you configure host redirection to a destination service, do not deploy a waypoint proxy for that service.