Canary Testing
An Application POC to display how with two different containers, you can route traffic via Headers with Istio.
Running app locally
To run locally simply run:
go run main.go /path/to/file
Once running to see the response:
curl http://localhost:9000
The application has two endpoints:
/
- returns <File Contents>
/headers
- returns headers sent to app
Docker
With the docker image, setting the build arg RES, will create a file with the contents of the value
docker build --build-arg RES=test-a -t canary-testing:a .
docker build --build-arg RES=test-b -t canary-testing:b .
Routing with Virtual Services
With the pod being labeled, with version: canary
, you can utilize virtual service and destination rules to route traffic to the new canary.
Define routing subsets:
# Destination Rule
...
subsets:
- labels:
version: canary
name: canary
- labels:
version: production
name: production
# Virtual Service
...
- name: canary-route
match:
- headers:
version:
exact: canary
route:
- destination:
host: app-canary-testing
subset: canary
...
Deploy with Helm
- Update values.yaml with host, ingress, or any other environment specific information.
helm upgrade -n $ISTIO_ENABLED_NAMESPACE app $PWD