We hope you read The first part, where we briefly explained what Canary Deployments are. We also showed how to implement it using standard Kubernetes resources.
Argo Rollouts
Argo Rollouts is a Kubernetes native deployment controller. It provides CRD (Custom Resource Definition) for Kubernetes. Thanks to him, we can use the new entity: Rollout, which manages blue-green and canary deployments with various customization options.
Argo Rollouts controller used by a custom resource Rollout, allows for additional deployment strategies such as blue-green and canary for Kubernetes. Resource Rollout provides equivalent functionality Deployment, only with additional deployment strategies.
Resource Deployments has two strategies for deployment: RollingUpdate и Recreate. Although these strategies are suitable for most cases, deploying to servers on a very large scale uses additional strategies such as blue-green or canary that are not in the Deployment controller. To use these strategies in Kubernetes, users had to write scripts on top of their Deployments. The Argo Rollouts controller exposes these strategies as simple declarative configurable parameters. https://argoproj.github.io/argo-rollouts
There is also Argo CI which provides a nice web interface to use with Rollouts, we'll take a look at it in the next article.
In our infrastructure turnip (see below), we have already added install.yaml as i/k8s/argo-rollouts/install.yaml. This way GitlabCI will install it on the cluster.
This is a very simple Python+Flask API that returns a JSON response. We will build the package using GitlabCI and push the result to the Gitlab Registry. In the registry, we have two different release versions:
wuestkamp/k8s-deployment-example-app:v1
wuestkamp/k8s-deployment-example-app:v2
The only difference between them is the returned JSON file. We use this app to visualize as easily as possible which version we are talking to.
infrastructure repository
In this repository we will be using GitlabCI to deploy to Kubernetes, .gitlab-ci.yml looks like this:
Rollout works the same way as Deployment. If we don't set an update strategy (like canary here) it will behave like the default rolling-update Deployment.
We define two steps in yaml for canary deployment:
10% traffic to canary (wait for manual OK)
50% traffic to canary (wait 2 minutes then continue to 100%)
Performing an Initial Deployment
After the initial deployment, our resources will look like this:
And we get a response only from the first version of the application:
Executing Canary Deployment
Step 1: 10% traffic
To start a canary deployment, we just need to change the version of the image, as we usually do with deployments:
I really recommend this video, it shows how Argo Rollouts and Argo CI work together:
Сonclusion
I really like the idea of using CRDs that manage the creation of additional types of deployments or replicasets, redirect traffic, etc. Working with them goes smoothly. Next, I would like to test the integration with Argo CI.
However, there appears to be a big merger between Argo CI and Flux CI, so I might wait until a new release comes out: Argo Flux.
Have you had any experience with Argo Rollouts or Argo CI?