
Istio: Traffic Routing
Here we use helm to install istio (istio-base, istiod, istio gateway), then deploy a sample online book store microservice "bookinfo". Practise istio tasks include Traffic Management, Observability, Security.
Bookinfo Topology:
- Helm install istio (istiod, istio-ingress)
kubectl create namespace istio-system helm pull istio/base helm install istio-base . -n istio-system --set defaultRevision=default helm pull istio/istiod helm install istiod . -n istio-system kubectl create namespace istio-ingress helm pull istio/gateway helm install istio-ingress . -n istio-ingress helm ls -n istio-system NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION istio-base istio-system 1 2023-12-17 08:14:06.943276388 +0800 CST deployed base-1.20.1 1.20.1 istiod istio-system 1 2023-12-17 08:15:40.370551503 +0800 CST deployed istiod-1.20.1 1.20.1 helm ls -n istio-ingress NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION istio-ingress istio-ingress 1 2023-12-17 08:25:07.111999373 +0800 CST deployed gateway-1.20.1 1.20.1
- Deploy bookinfo microservice and istio ingressgateway and virtualservice
kubectl label namespace istio-system istio-injection=enabled kubectl apply -f https://github.com/istio/istio/blob/master/samples/bookinfo/platform/kube/bookinfo.yaml -oyaml > bookinfo.yaml kubectl apply -f bookinfo.yaml kubectl get po NAME READY STATUS RESTARTS AGE details-v1-698d88b-wmfcb 2/2 Running 0 21m ratings-v1-6484c4d9bb-cb6gx 2/2 Running 0 21m reviews-v1-5b5d6494f4-jrsvc 2/2 Running 0 21m reviews-v2-5b667bcbf8-jgfzj 2/2 Running 0 21m reviews-v3-5b9bd44f4-tmmfz 2/2 Running 0 21m kubectl apply -f https://github.com/istio/istio/blob/master/samples/bookinfo/networking/bookinfo-gateway.yaml -oyaml > bookinfo-gateway.yaml kubectl apply -f bookinfo-gateway.yaml
- Deploy Kiali, jaeger, grafana, prometheus
wget https://raw.githubusercontent.com/istio/istio/release-1.20/samples/addons/prometheus.yaml wget https://raw.githubusercontent.com/istio/istio/release-1.20/samples/addons/jaeger.yaml wget https://raw.githubusercontent.com/istio/istio/release-1.20/samples/addons/grafana.yaml kubectl create -f prometheus.yaml -f jaeger.yaml -f grafana.yaml
- Visit http://book.istio:31000/productpage, with review (v1, v2, v3)
- Define destination rules and virtual service for reviews
wget https://raw.githubusercontent.com/istio/istio/master/samples/bookinfo/networking/destination-rule-all.yaml wget https://raw.githubusercontent.com/istio/istio/master/samples/bookinfo/networking/virtual-service-reviews-90-10.yaml kubectl create -f destination-rule-all.yaml -f virtual-service-reviews-90-10.yaml # route v1 10% and v3 90% kubectl scale deployment reviews-v2 -n istio-system --replicas=0 # scale down v2 to 0 kubectl get dr -A NAMESPACE NAME HOST AGE istio-system details details 6m56s istio-system productpage productpage 6m56s istio-system ratings ratings 6m56s istio-system reviews reviews 6m56s kubectl get vs -A NAMESPACE NAME GATEWAYS HOSTS AGE istio-system bookinfo ["bookinfo-gateway"] ["book.istio"] 19h istio-system reviews ["reviews"] 5m26s Spec: Hosts: reviews Http: Route: Destination: Host: reviews Subset: v1 Weight: 10 Destination: Host: reviews Subset: v3 Weight: 90
Refresh the bookinfo webpage, test Traffic route weight as below:
90% traffic for reviews v3 vs 10% traffic for review v1