Deploy Canary Set Up
Clone the repository
cd ~/environment
git clone https://github.com/aws-containers/eks-microservice-demo.git
cd eks-microservice-demo
Create a namespace and a mesh
kubectl apply -f flagger/mesh.yaml
Create a deployment and a horizontal pod autoscaler
export APP_VERSION=1.0
envsubst < ./flagger/flagger-app.yaml | kubectl apply -f -
Create IAM policy and Role for flagger-loadtester
# Create an IAM policy called AWSAppMeshK8sControllerIAMPolicy
aws iam create-policy \
--policy-name FlaggerEnvoyNamespaceIAMPolicy \
--policy-document file://envoy-iam-policy.json
# Create an IAM service account for flagger namespace
eksctl create iamserviceaccount --cluster eksworkshop-eksctl \
--namespace flagger \
--name flagger-envoy-proxies \
--attach-policy-arn arn:aws:iam::$ACCOUNT_ID:policy/FlaggerEnvoyNamespaceIAMPolicy \
--override-existing-serviceaccounts \
--approve
Deploy the load testing service to generate traffic during the canary analysis
helm upgrade -i flagger-loadtester flagger/loadtester \
--namespace=flagger \
--set appmesh.enabled=true \
--set "appmesh.backends[0]=detail" \
--set "appmesh.backends[1]=detail-canary" \
--set "serviceAccountName=flagger-envoy-proxies"
Create a canary definition
Now lets deploy the Flagger canary definition file for detail
service
kubectl apply -f flagger/flagger-canary.yaml
You can see the below objects being created by flagger
kubectl -n appmesh-system logs deploy/flagger --tail 15 -f | jq .msg
You should see the below event from canary
kubectl -n flagger describe canary/detail
After the bootstrap is completed,
detail
deployment is scaled to zero.
- Traffic to
detail.flagger
will be routed to the primary pods.
- AppMesh resources like virtualnode, virtualservice, virtualrouter has been created for the
detail
service
kubectl get pod,deployment,svc,virtualnode,virtualservice,virtualrouter -n flagger
Testing the setup
Exec into flagger-loadtester pod
kubectl exec deploy/flagger-loadtester -n flagger -it bash
Curl to detail
service to confirm if you get response from the deployed service
curl http://detail.flagger:3000/catalogDetail
Congratulations! You have set up the canary analysis for backend service detail
succcessfuly.