This is the third post in a Progressive Delivery series, see the previous ones:
Progressive Delivery is used by Netflix, Facebook and others to reduce the risk of deployments. But you can now adopt it when using Jenkins X .
Progressive Delivery is the next step after Continuous Delivery, where new versions are deployed to a subset of users and are evaluated in terms of correctness and performance before rolling them to the totality of the users and rolled back if not matching some key metrics.
In particular we focused on Canary releases and made it really easy to adopt them in your Jenkins X applications. Canary releases consist on sending a small percentage of traffic to the new version of your application and validate there are no errors before rolling it out to the rest of the users. Facebook does it this way, delivering new versions first to internal employees, then a small percentage of the users, then everybody else, but you don’t need to be Facebook to take advantage of it!
If you already have an application in Jenkins X you know that you can promote it to the “production” environment with
jx promote myapp --version 1.0 --env production . But it can also be automatically and gradually rolled it out to a percentage of users while checking that the new version is not failing. If that happens the application will be automatically rolled back. No human intervention at all during the process.
NOTE: this new functionality is very recent and a number of these steps will not be needed in the future as they will also be automated by Jenkins X.
As the first step three Jenkins X addons need to be installed:
Prometheus : the most popular monitoring system in Kubernetes.
Flagger : a project that uses Istio to automate canarying and rollbacks using metrics from Prometheus.
The addons can be installed (using a recent version of the
jx cli) with
This will enable Istio in the
jx-production namespace for metrics gathering.
Now get the ip of the Istio ingress and point a wildcard domain to it (e.g.
*.example.com ), so we can use it to route multiple services based on host names. The Istio ingress provides the routing capabilities needed for Canary releases (traffic shifting) that the traditional Kubernetes ingress objects do not support.
The cluster is configured, and it’s time to configure our application. Add a
canary.yaml to your helm chart, under
Then append to the
charts/myapp/values.yaml the following, changing
myapp.example.com to your host name or names:
Soon, both the
canary.yaml values.yaml changes won’t be needed when you create your app from one of the Jenkins X quickstarts, as they will be Canary enabled by default.
That’s it! Now when the app is promoted to the production environment with
jx promote myapp --version 1.0 --env production it will do a Canary rollout. Note that the first time it is promoted it will not do a Canary as it needs a previous version data to compare to, but it will work from the second promotion on.
With the configuration in the
values.yaml file above it would look like:
minute 1: send 10% of the traffic to the new version
minute 2: send 20% of the traffic to the new version
minute 3: send 30% of the traffic to the new version
minute 4: send 40% of the traffic to the new version
minute 5: send 100% of the traffic to the new version
If the metrics we have configured (request duration over 500 milliseconds or more than 1% responses returning 500 errors) fail, Flagger then will note that failure, and if it is repeated 5 times it will rollback the release, sending 100% of the traffic to the old version.
To get the Canary events run
Flagger includes a Grafana dashboard for visualization purposes as it is not needed for the Canary releases. It can be accessed locally using Kubernetes port forwarding
Then accessing http://localhost:3000 using
admin/admin , selecting the
canary-analysis dashboard and
would provide us with a view of different metrics (cpu, memory, request duration, response errors,…) of the incumbent and new versions side by side.
Note that Istio by default will prevent access from your pods to the outside of the cluster (a behavior that is expected to change in Istio 1.1). Learn how to control the Istio egress traffic .
If a rollback happens automatically because the metrics fail, the Jenkins X GitOps repository for the production environment becomes out of date, still using the new version instead of the old one. This is something planned to be fixed in next releases.
Stay up to date
We'll never share your email address and you can opt out at any time, we promise.