-
Notifications
You must be signed in to change notification settings - Fork 10
Lab 6: Canary upgrades
Let's say to test a canary, you want 80% of the traffic to go to version 1 of the frontend and 20% to version 2. We can do that by editing the virtual service and adding a destination rule like below. The new destination rule will route traffic to the planespotter-frontend, notice the host here mentioned the planespotter-frontend service.
Using Kubernetes autoscaler plus Istio a canary rollout of version 1 and 2 can be automatically managed rather than having to control the ratio of pods in version 1 and version 2 by taking advantage of virtualservices.
Route 80% of the traffic to Version 1 and 20% traffic to version 2.
Virtual service edited to add route based on weight.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: planespotter
spec:
hosts:
- "*"
gateways:
- planespotter-gateway
http:
- match:
- uri:
exact: /index.html
- uri:
exact: /registry.html
- uri:
exact: /details.html
- uri:
exact: /health.html
- uri:
exact: /contact.html
- uri:
prefix: /static
route:
- destination:
host: planespotter-frontend
subset: v2
weight: 20
- destination:
host: planespotter-frontend
subset: v1
weight: 80
Add destination rules to route traffic from the virtual service to both versions of the app.
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: frontend-destination
spec:
host: planespotter-frontend.planespotter.svc.cluster.local
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2
Delete the virtualservice from the previous lab:
kubectl delete virtualservice planespotter -n planespotter
Apply the new virtual service
kubectl apply -f https://raw.githubusercontent.com/Boskey/planespotter/master/kubernetes/planespotter-virtualservice-css-80-20.yaml -n planespotter
Ensure the service is created
`kubectl get virtualservices -n planespotter
Create destination rule:
kubectl apply -f https://raw.githubusercontent.com/Boskey/planespotter/master/kubernetes/frontend-destination-rule.yaml -n planespotter
Now refresh your browser a couple of times, you will notice v1 of the frontend (which is the Contacts page) visible more version 2 ( which is the feedback page)
This may take a few minutes to take effect.