In Part 1 of Argo Rollout, we have seen the Blue-Green deployment strategy and deployed a sample app for the same using the Argo Rollout controller in the Kubernetes cluster.
In this hands-on lab, we will be going to explore the canary deployment strategy via deploying a sample app using the Argo Rollout.
Lab Setup
You can start the lab setup by clicking on the Lab Setup button on the right side of the screen. Please note that there are app-specific URLs exposed specifically for the hands-on lab purpose.
Our lab has been set up with all necessary tools like base OS (Ubuntu), developer tools like Git, Vim, wget, and others.
Lab of Argo Rollout with Canary Deployments
As we triggered the lab through the LAB SETUP button, a terminal, and an IDE comes for us which already have a Kubernetes cluster running in it. This can be checked by running the kubectl get nodes
command.
- Clone the Argo Rollouts example GitHub repo or preferably, please fork this
git clone https://github.com/NiniiGit/argo-rollouts-example.git
Installation of Argo Rollouts controller
- Create the namespace for installation of the Argo Rollouts controller and Install the Argo Rollout through the below command, more about the installation can be found here.
kubectl create namespace argo-rollouts
kubectl apply -n argo-rollouts -f https://github.com/argoproj/argo-rollouts/releases/latest/download/install.yaml
You will see that the controller and other components have been deployed. Wait for the pods to be in the Running
state.
kubectl get all -n argo-rollouts
- Install Argo Rollouts Kubectl plugin with
curl
for easy interaction with Rollout controller and resources.
curl -LO https://github.com/argoproj/argo-rollouts/releases/latest/download/kubectl-argo-rollouts-linux-amd64
chmod +x ./kubectl-argo-rollouts-linux-amd64
sudo mv ./kubectl-argo-rollouts-linux-amd64 /usr/local/bin/kubectl-argo-rollouts
kubectl argo rollouts version
- Argo Rollouts comes with its own GUI as well that you can access with the below command
kubectl argo rollouts dashboard
and now by clicking on the available argo-rollout-app
URL on the right side under the LAB-URLs section.
you would be presented with UI as shown below(currently it won't show you anything since we are yet to deploy any Argo Rollouts based)
Now, let's go ahead and deploy the sample app using the Canary Deployment strategy.
Canary Deployment with Argo Rollouts
To experience how the Canary deployment works with Argo Rollouts, we will deploy the sample app which contains Rollouts with canary strategy, Service, and Ingress as Kubernetes objects.
rollout.yaml
content:
service.yaml
content:
ingress.yaml
content:
- Now, let's create all these objects for now in the `default` namespace. Please execute the below commands
kubectl apply -f argo-rollouts-example/canary-deployment-example/
You would be able to see all the objects been created in the default
namespace by running the below commands
kubectl get all
Now, you can access your sample app, by clicking on the app-port-80
URL under the LAB-URLs section.
- You would be able to see the app as shown below:
- Now, again visit the Argo-Rollouts console through the
app-rollout-app
URL. And this time, you could see the sample deployed on the Argo Rollouts console as below
You can click on this rollout-demo
in the console and it will present you with its current status of it as below
Again, either you can use this GUI or else (preferably) use the command shown below to continue with this demo.
- You can see the current status of this rollout by running the below command as well
kubectl argo rollouts get rollout rollouts-demo
- Now, let's deploy the Yellow version of the app using canary strategy via command line
kubectl argo rollouts set image rollouts-demo rollouts-demo=argoproj/rollouts-demo:yellow
You would be able to see a new i.e yellow version-based pod of our sample app, coming up.
kubectl get pods
Currently, only 20% i.e 1 out of 5 pods with a yellow version will come online, and then it will be paused
as we have mentioned in the steps above. See line number 9 in the rollout.yaml
Also on the Argo console, you would be able to see below the kind of new revision of the app with the changed image version running.
If you visit the app URL on app-port-80
, you would still see only the majority of blue version, and a very less number of yellow is visible rightly because we have not yet fully promoted the yellow version of our app.
- You can confirm the same now, by running the command below, which shows, the new version is in
paused
state
kubectl argo rollouts get rollout rollouts-demo
- Now, let's promote the yellow version of our app, by executing the below command
kubectl argo rollouts promote rollouts-demo
Run the following command and you would see it's scaling the new i.e yellow version of our app completely.
kubectl argo rollouts get rollout rollouts-demo
The same can be confirmed by running the below command, which shows the old set of pods i.e old blue version of our app, terminating or already terminated.
kubectl get pods
- Eventually, if you visit the app URL on
app-port-80
this time, you would see only the Yellow version is visible right now because we have fully promoted the yellow version of our app
Kudos!! you have successfully completed the Canary Deployment using Argo Rollouts.
- you can also delete this entire setup i.e our sample deployed app using the below command.
kubectl delete -f argo-rollouts-example/canary-deployment-example/
What Next?
As you developed an understanding of canary deployment and deployed a sample through it. Now, you can try the next hands-on lab about canary deployment with analysis using Argo Rollouts.
Conclusion
In this hands-on lab, we saw about canary deployment and how to create it using Argo Rollouts.