You configure rollback as a pipeline with tasks that return your deployment to a previous stable state following a failure in a deployment pipeline. To roll back if a failure occurs, you attach the rollback pipeline to tasks or stages.
Depending upon your role, your reasons for rollback might vary.
- As a release engineer, I want Automation Pipelines to verify success during a release so that I can know whether to continue with the release or roll back. Possible failures include task failure, a rejection in UserOps, exceeding the metrics threshold.
- As an environment owner, I want to redeploy a previous release so that I can quickly get an environment back to a known-good state.
- As an environment owner, I want to support roll back of a Blue-Green deployment so that I can minimize downtime from failed releases.
When you use a smart pipeline template to create a CD pipeline with the rollback option clicked, rollback is automatically added to tasks in the pipeline. In this use case, you will use the smart pipeline template to define rollback for an application deployment to a Kubernetes cluster using the rolling upgrade deployment model. The smart pipeline template creates a deployment pipeline and one or more rollback pipelines.
- In the deployment pipeline, rollback is required if Update Deployment or Verify Deployment tasks fail.
- In the rollback pipeline, deployment is updated with an old image.
You can also manually create a rollback pipeline using a blank template. Before creating a rollback pipeline, you will want to plan your rollback flow. For more background information about rollback, see Planning for rollback in Automation Pipelines.
Prerequisites
- Verify that you are a member of a project in Automation Pipelines. If you are not, ask a Automation Pipelines administrator to add you as a member of a project. See How do I add a project in Automation Pipelines.
- Set up the Kubernetes clusters where your pipeline will deploy your application. Set up one development cluster and one production cluster.
- Verify that you have a Docker registry setup.
- Identify a project that will group all your work, including your pipeline, endpoints, and dashboards.
- Familiarize yourself with the CD smart template as described in the CD portion of Planning a CICD native build in Automation Pipelines before using the smart pipeline template, for example:
- Create the Kubernetes development and production endpoints that deploy your application image to the Kubernetes clusters.
- Prepare the Kubernetes YAML file that creates the Namespace, Service, and Deployment. If you need to download an image from a privately-owned repository, the YAML file must include a section with the Docker config Secret.
Procedure
- Click .
- Enter the information in the smart pipeline template.
- Select a project.
- Enter a pipeline name such as RollingUpgrade-Example.
- Select the environments for your application. To add rollback to your deployment, you must select Prod.
- Click Select, choose a Kubernetes YAML file, and click Process.
The smart pipeline template displays the available services and deployment environments.
- Select the service that the pipeline will use for the deployment.
- Select the cluster endpoints for the Dev environment and the Prod environment.
- For the Image source, select Pipeline runtime input.
- For the Deployment model, select Rolling Upgrade.
- Click Rollback.
- Provide the Health check URL.
- To create the pipeline named RollbackUpgrade-Example, click Create.
The pipeline named RollbackUpgrade-Example appears, and the rollback icon appears on tasks that can roll back in the Development stage and the Production stage.
- Close the pipeline.
On the Pipelines page, the pipeline that you created appears, and a new pipeline for each stage in your pipeline appears.
- RollingUpgrade-Example. Automation Pipelines deactivates the pipeline that you created by default, which ensures that you review it before you run it.
- RollingUpgrade-Example_Dev_Rollback. Failure of tasks in the development stage, such as Create service, Create secret, Create deployment, and Verify deployment invoke this rollback development pipeline. To ensure the rollback of development tasks, Automation Pipelines activates the rollback development pipeline by default.
- RollingUpgrade-Example_Prod_Rollback. Failure of tasks in the production stage, such as Deploy phase 1, Verify phase 1, Deploy Rollout phase, Finish Rollout phase, and Verify rollout phase invoke this rollback production pipeline. To ensure the rollback of production tasks, Automation Pipelines activates the rollback production pipeline by default.
- Enable and run the pipeline you created.
When you start the run,
Automation Pipelines prompts you for input parameters. You provide the image and tag for the endpoint in the Docker repository that you are using.
- On the Executions page, select and watch the pipeline execution.
The pipeline starts RUNNING and moves through the Development stage tasks. If the pipeline fails to run a task during the Development stage, the pipeline named RollingUpgrade-Example_Dev_Rollback triggers and rolls back the deployment, and the pipeline status changes to ROLLING_BACK.
After rollback, the Executions page lists two RollingUpgrade-Example pipeline executions.
- The pipeline you created rolled back and displays ROLLBACK_COMPLETED.
- The rollback development pipeline that triggered and performed the rollback displays COMPLETED.
Results
Congratulations! You successfully defined a pipeline with rollback and watched
Automation Pipelines roll back the pipeline at the point of failure.