CANARY DEPLOYMENT IN AZURE KUBERNETES SERVICE
Part 3: Deploying React App to Kubernetes
Bonjour,
This is the final blog of our series. In this Blog I’ll help you with:
1. Creating a Jenkins Multi-Branch Project
2. Run Your first build
3. Edit Service and add DNS to your Service Load Balancer
4. Finally, set up your Traffic Manager
SETUP JENKINS MULTI-BRANCH PIPELINE
- Open your Jenkins and click on new Item
- Enter the name of your project, example: aks-demo and select the Multi-Branch Pipeline. Click in OK
3. In the Branch Source, select git and add the repository that you forked in the previous blog of this series.
4. Save the changes and you are all set to run your first Build.
Run Your First build
After the images are pushed to docker hub, canary deployment stage will run, It will create a Kubernetes Service and Deployment Objects. And then the pipeline will wait for your approval to deploy the app to production. Once you click on proceed, the canary will be deployed to production and the pipeline will delete the canary deployment.
Edit Service and add DNS to your Service Load Balancer
Azure Traffic Manager is a DNS-based traffic load balancer. So we have edit the service and add a dns label metadata.
apiVersion: v1
kind: Service
metadata:
name: frontend-svc-canary
annotations:
service.beta.kubernetes.io/azure-dns-label-name:<DNS-LABEL>
Set up your Traffic Manager
- Open your Azure Portal and select Traffic Manager
- Add a new Profile, Give the name, select Routing method as weighted, and select the Resource group in which your kubernetes cluster is created. Finally click on create
- select your newly created profile
- In the setting click on Endpoints, and create two Endpoints. Name one of them as canary-deployment and other as production.
5. In Target resource Type, select Public IP Address.
6. Select your respective service load balancer public IP address. Click on Add
{YOU MUST CREATE A DNS-LABEL FOR YOUR SERVICE OTHERWISE YOU CANNOT USE IT. IF YOU HAVE FOLLOWED THE BLOG, WE HAVE ACHIEVED IT IN THIRD STEP}
You are all set, 20% of your traffic will be routed to the canary deployment and remaining 80% to production.
Hope you enjoyed reading this blog. If you have any doubts, or faced any problem regarding this, you can reach out to me on my facebook page.
Happy Coding!!