Canary deployment
In this lab we are going to create a canary deployment. The idea behind canary deployment (or rollout) is to introduce a new version of an application by first testing it using a small percentage of user traffic, and then if all goes well increasing the percentage while simultaneously phasing out the old version.
For this we are going to deploy the stable version (blue), introduce a new version and then change the new version until we are happy with it and then increase the traffic to the new version.
Prepare images
For this lab we need the 2 images (blue
and green
) we already created in the previous labs. If you haven't created the blue and green images, first complete these 4 labs:
Or you can use public images e.g. nginx:latest
and tomcat:latest
for this lab.
Create a workload from the catalog
Go to the list of builds and add the repository of the green build to your clipboard.
-
Go to Workloads in the left menu and click on Create Workload.
-
Select
k8s-deployment-canary
from the catalog. -
Add the Name canary for the workload.
-
Set the Auto image updater to Digest and fill in:
- imageRepository : paste from the clipboard
- imageParameter :
versionTwo.image.repository
- tagParameter :
versionTwo.image.tag
-
In the workload values, change the following parameters:
# For the v1 as the stable version versionOne: image: repository: # paste from clipboard, but change to blue tag: main # The v2 as canary with the auto image updater configured versionTwo: image: repository: # paste from clipboard. This will be the green image tag: main
-
Click Submit
We now created two deployments. One for blue and one for green. The green image (our canary) will be automatically updated after a change (commit).
Expose the service
-
In the left menu panel under click Services then click on Create Service.
-
Select the canary service from the drop-down list.
-
Click on Advanced Settings.
-
Click on Enable Traffic Management (and use the default weights for v1 and v2).
-
Click Create Service.
See the results
You will see the canary service in the list of Services. Click on the URL and refresh the page for a couple of times. You should first see:
After a refresh of the page you should see:
Update the canary image
Go to the green repo and change the background color (background-color
) in the green.html
file from green
to MediumSeaGreen
and commit the change. After a couple of minutes you should now see that the background color of version 2 has changed.
Do you see the difference?
Updated 20 days ago