Layer 7 routing in Service Mesh (ASM) routes traffic based on URI paths and request headers. Before you configure routing rules, set up your ASM environment and deploy the sample workloads that the routing tutorials reference.
This topic covers two steps: confirm that your ASM instance, ACK cluster, and sidecar injection are ready, then deploy the sample services used in the routing tutorials.
Prerequisites
Before you begin, make sure that you have:
A Service Mesh (ASM) instance of Enterprise Edition. See Create an ASM instance.
ImportantIn the Dataplane Mode section of the Create Service Mesh page, do not select Enable Ambient Mesh mode. The Layer 7 routing features in this guide require sidecar mode.
A Container Service for Kubernetes (ACK) cluster. Create either an ACK dedicated cluster or an ACK managed cluster
Automatic sidecar proxy injection enabled for the
defaultnamespace. See the "Enable automatic sidecar proxy injection" section in Manage global namespaces
Deploy sample workloads
The Layer 7 routing tutorials use four sample services. Deploy only the services required for the tutorial you plan to follow.
| Service | Purpose | Listens on |
|---|---|---|
| helloworld | Multi-version service (v1, v2) for testing version-based routing and traffic splitting | Port 5000 |
| sleep | Client pod with curl for sending test requests to other services in the mesh | Port 80 |
| HTTPBin | HTTP testing endpoint that echoes request details (headers, paths, methods) back to the caller | Port 8000 |
| NGINX | Static web server for testing basic routing rules | Port 8000 |
Connect kubectl to your ACK cluster using the kubeconfig file, then follow the sections below.
Deploy the helloworld service
helloworld runs two versions (v1 and v2) of the same application. This makes it suitable for testing version-based routing and traffic splitting.
Save the following YAML as
helloworld-application.yaml:Deploy the service:
kubectl apply -f helloworld-application.yamlVerify the deployment: Expected output: A
READYvalue of2/2confirms that both the application container and the sidecar proxy are running.kubectl get pods -l app=helloworldNAME READY STATUS RESTARTS AGE helloworld-v1-xxxxxxxxx-xxxxx 2/2 Running 0 30s helloworld-v2-xxxxxxxxx-xxxxx 2/2 Running 0 30s
Deploy the sleep service
sleep acts as a client pod. It stays idle and provides a curl environment for sending test requests to other services in the mesh.
Save the following YAML as
sleep-application.yaml:Deploy the service:
kubectl apply -f sleep-application.yamlVerify the deployment: Expected output:
kubectl get pods -l app=sleepNAME READY STATUS RESTARTS AGE sleep-xxxxxxxxx-xxxxx 2/2 Running 0 30s
Deploy the HTTPBin service
HTTPBin echoes back request details -- headers, URI paths, and methods. Use it to verify that routing rules forward requests to the correct destination.
Save the following YAML as
httpbin-application.yaml:Deploy the service:
kubectl apply -f httpbin-application.yamlVerify the deployment: Expected output:
kubectl get pods -l app=httpbinNAME READY STATUS RESTARTS AGE httpbin-xxxxxxxxx-xxxxx 2/2 Running 0 30s
Deploy the NGINX service
NGINX serves static content. Use it in tutorials that demonstrate basic URI path routing.
Save the following YAML as
nginx.yaml:Deploy the service:
kubectl apply -f nginx.yamlVerify the deployment: Expected output:
kubectl get pods -l app=nginxNAME READY STATUS RESTARTS AGE nginx-xxxxxxxxx-xxxxx 2/2 Running 0 30s
Verify all deployments
After you deploy the required services, confirm that all pods are running with sidecar injection:
kubectl get podsEvery pod should show 2/2 in the READY column. This confirms that both the application container and the Istio sidecar proxy are injected and running.