In this demo, you will learn how to use the baggage header to control the routing of your services.
Architecture:
Clone the repository
git clone git@github.com:antonioberben/test-in-production.git
cd test-in-production Deploy Istio
istioctl install -f ./k8s/istio-values.yaml -yDeploy the services
kubectl create ns my-system
kubectl label namespace my-system istio.io/rev=1-21 --overwrite
kubectl apply -f ./k8s/app.yaml
kubectl apply -f ./k8s/app3-new-version.yamlDeploy the Istio Resources
kubectl apply -f ./k8s/istio-virtualservice.yamlTest the services
kubectl port-forward -n my-system svc/app1 5000And then
curl localhost:5000/product/123You will see the response from app1, app2 and app3 together:
Hello from API 1!
Hello from API 2!
Hello from API 3!
Now, adding the baggage header which will be propagated across the services:
curl localhost:5000/product/123 -H "baggage: pr=123"You will see the response from app3 with the blue version:
Hello from API 1!
Hello from API 2!
Hello from API 3! This is a new version of the app
Checking the logs for the proxy,
kubectl logs -n my-app deploy/app3 -n my-system -c istio-proxy --tail 1You will see outputted the baggage header that was passed to the application. Notice that app1 added some extra baggage.
[ACCES_LOGS] "baggage": "x=1,pr=123,product-id=123,other-baggage=value2,another-baggage=3,url-baggage=%2Ftest%2F1%3Fattr%3D1" "authority": "app3.my-system.svc.cluster.local:5000" "method": "GET" "path": "/"
