How do we perform rollbacks?

Learn how to rollback to previous releases of helm apps.

Question

How to rollback application to previous version?

Answer

Helm handles rollbacks out-of-the-box. Everytime a helm release is performed, it creates a new revision. By pinpointing a specific helm revision and performing a rollback, the previous version will be redeployed.

There are a couple ways we recommend performing rollbacks.

Rollback using Helm Client

Start the Geodesic Shell

Run the Geodesic shell followed by assume-role

sh-3.2$ $CLUSTER_NAME

Run the Geodesic Shell

sh-3.2$ staging.example.com
# Mounting /home/goruha into container
# Starting new staging.example.com session from cloudposse/staging.example.com:dev
# Exposing port 41179
* Started EC2 metadata service at http://169.254.169.254/latest

         _              _                                              _
     ___| |_ __ _  __ _(_)_ __   __ _    _____  ____ _ _ __ ___  _ __ | | ___
    / __| __/ _` |/ _` | | '_ \ / _` |  / _ \ \/ / _` | '_ ` _ \| '_ \| |/ _ \
    \__ \ || (_| | (_| | | | | | (_| | |  __/>  < (_| | | | | | | |_) | |  __/
    |___/\__\__,_|\__, |_|_| |_|\__, |  \___/_/\_\__,_|_| |_| |_| .__/|_|\___|
                  |___/         |___/                           |_|


IMPORTANT:
* Your $HOME directory has been mounted to `/localhost`
* Use `aws-vault` to manage your sessions
* Run `assume-role` to start a session


-> Run 'assume-role' to login to AWS
 ⧉  staging example
❌   (none) ~ ➤

Then login to AWS by running assume-role:

Assume role

❌   (none) conf ➤  assume-role
Enter passphrase to unlock /conf/.awsvault/keys/:
Enter token for arn:aws:iam::xxxxxxx:mfa/goruha: 781874
* Assumed role arn:aws:iam::xxxxxxx:role/OrganizationAccountAccessRole
-> Run 'init-terraform' to use this project
 ⧉  staging example
✅   (example-staging-admin) conf ➤

Configure kubectl and helm

When you start the Geodesic shell, you will need to export the kubecfg which provides the TLS client certificates necessary for kubectl and helm to authenticate with the cluster.

Export kops config

✅   (example-staging-admin) ~ ➤  kops export kubecfg $KOPS_CLUSTER_NAME
kops has set your kubectl context to us-west-2.staging.example.com

Rollback Helm Release

Run the following commands to identify the helm release and corresponding revision that you want to rollback to. Note, we’re using $RELEASE_NAME and $REVISION_NUMBER to symbolically represent the values you should enter in their place.

sh-3.2 $ helm list
sh-3.2 $ helm history $RELEASE_NAME
sh-3.2 $ helm rollback $RELEASE_NAME $REVISION_NUMBER

Helm rollback

✅   (example-staging-admin) ~ ➤  helm list
NAME                    REVISION        UPDATED                STATUS            CHART             NAMESPACE
catalogue-master           21     Fri May 25 14:36:47 2018    DEPLOYED   catalogue-0.4.0-master   demo-master
frontend-master            20     Wed Mar 14 03:23:05 2018    DEPLOYED   frontend-0.3.12-master   demo-master
 ⧉  cluster-4.cloudposse.com
✅   (example-staging-admin) ~ ➤  helm history catalogue-master
 REVISION        UPDATED                         STATUS          CHART                   DESCRIPTION
1               Fri Jan 19 05:58:39 2018        SUPERSEDED      catalogue-0.3.5-master  Install complete
2               Tue Jan 23 20:17:47 2018        SUPERSEDED      catalogue-0.3.5-master  Upgrade complete
3               Thu Jan 25 13:00:21 2018        SUPERSEDED      catalogue-0.3.5-master  Upgrade complete
4               Thu Jan 25 13:18:30 2018        SUPERSEDED      catalogue-0.3.5-master  Upgrade complete
5               Thu Jan 25 13:22:13 2018        SUPERSEDED      catalogue-0.3.5-master  Upgrade complete
6               Fri Feb  9 03:50:43 2018        SUPERSEDED      catalogue-0.3.5-master  Upgrade complete
7               Fri Feb  9 18:54:30 2018        SUPERSEDED      catalogue-0.3.6-master  Upgrade complete
8               Sat Feb 17 02:24:01 2018        SUPERSEDED      catalogue-0.3.6-master  Upgrade complete
9               Fri Mar  9 20:50:52 2018        SUPERSEDED      catalogue-0.3.7-master  Upgrade complete
10              Fri Mar  9 20:54:59 2018        SUPERSEDED      catalogue-0.3.7-master  Upgrade complete
11              Mon Mar 12 06:08:16 2018        SUPERSEDED      catalogue-0.3.7-master  Upgrade complete
12              Mon Mar 12 15:36:25 2018        SUPERSEDED      catalogue-0.3.7-master  Upgrade complete
13              Mon Mar 12 19:50:52 2018        SUPERSEDED      catalogue-0.3.9-master  Upgrade complete
14              Wed Mar 14 04:35:19 2018        SUPERSEDED      catalogue-0.3.9-master  Upgrade complete
15              Wed Mar 14 04:47:10 2018        SUPERSEDED      catalogue-0.3.9-master  Upgrade complete
16              Wed Mar 14 04:54:18 2018        SUPERSEDED      catalogue-0.3.9-master  Upgrade complete
17              Wed Mar 14 14:50:30 2018        SUPERSEDED      catalogue-0.3.9-master  Upgrade complete
18              Wed Mar 14 15:02:58 2018        SUPERSEDED      catalogue-0.3.9-master  Upgrade complete
19              Fri Mar 16 01:02:26 2018        SUPERSEDED      catalogue-0.3.9-master  Upgrade complete
20              Fri May 25 08:36:53 2018        SUPERSEDED      catalogue-0.4.0-master  Upgrade complete
21              Fri May 25 14:36:47 2018        DEPLOYED        catalogue-0.4.0-master  Upgrade complete
✅   (example-staging-admin) ~ ➤  helm rollback catalogue-master 19
Rollback was a success! Happy Helming!
REVISION        UPDATED                         STATUS          CHART                   DESCRIPTION
1               Fri Jan 19 05:58:39 2018        SUPERSEDED      catalogue-0.3.5-master  Install complete
2               Tue Jan 23 20:17:47 2018        SUPERSEDED      catalogue-0.3.5-master  Upgrade complete
3               Thu Jan 25 13:00:21 2018        SUPERSEDED      catalogue-0.3.5-master  Upgrade complete
4               Thu Jan 25 13:18:30 2018        SUPERSEDED      catalogue-0.3.5-master  Upgrade complete
5               Thu Jan 25 13:22:13 2018        SUPERSEDED      catalogue-0.3.5-master  Upgrade complete
6               Fri Feb  9 03:50:43 2018        SUPERSEDED      catalogue-0.3.5-master  Upgrade complete
7               Fri Feb  9 18:54:30 2018        SUPERSEDED      catalogue-0.3.6-master  Upgrade complete
8               Sat Feb 17 02:24:01 2018        SUPERSEDED      catalogue-0.3.6-master  Upgrade complete
9               Fri Mar  9 20:50:52 2018        SUPERSEDED      catalogue-0.3.7-master  Upgrade complete
10              Fri Mar  9 20:54:59 2018        SUPERSEDED      catalogue-0.3.7-master  Upgrade complete
11              Mon Mar 12 06:08:16 2018        SUPERSEDED      catalogue-0.3.7-master  Upgrade complete
12              Mon Mar 12 15:36:25 2018        SUPERSEDED      catalogue-0.3.7-master  Upgrade complete
13              Mon Mar 12 19:50:52 2018        SUPERSEDED      catalogue-0.3.9-master  Upgrade complete
14              Wed Mar 14 04:35:19 2018        SUPERSEDED      catalogue-0.3.9-master  Upgrade complete
15              Wed Mar 14 04:47:10 2018        SUPERSEDED      catalogue-0.3.9-master  Upgrade complete
16              Wed Mar 14 04:54:18 2018        SUPERSEDED      catalogue-0.3.9-master  Upgrade complete
17              Wed Mar 14 14:50:30 2018        SUPERSEDED      catalogue-0.3.9-master  Upgrade complete
18              Wed Mar 14 15:02:58 2018        SUPERSEDED      catalogue-0.3.9-master  Upgrade complete
19              Fri Mar 16 01:02:26 2018        SUPERSEDED      catalogue-0.3.9-master  Upgrade complete
20              Fri May 25 08:36:53 2018        SUPERSEDED      catalogue-0.4.0-master  Upgrade complete
21              Fri May 25 14:36:47 2018        SUPERSEDED      catalogue-0.4.0-master  Upgrade complete
22              Fri May 25 15:42:00 2018        DEPLOYED        catalogue-0.3.9-master  Rollback to 19

Rollback using Codefresh UI

The other option is to use the Codefresh UI to perfom the rollback. The benefit with this is no console access is required.

Codefresh provides native integration with Kubernetes and Helm. Here’s an example of how you can use their UI to perform a rollback.

  1. Open the Helm Releases page

    List Releases

  2. Find the release you want to update and click on it

    View Release

  3. Select the release “History” tab

    Release History

  4. Click on rollback button next to the corresponding revision you wish to restore

    Rollback to Revision

  5. Confirm the rollback

    Confirm Rollback

  6. Wait until rollback finishes

  7. Refresh page and check that the new revision appears

    Rollback Completed