> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/continuous-delivery/3.0/use-deployments/kubernetes/step-library/k8s-rolling-rollback.md).

# Kubernetes Rolling Rollback

The Kubernetes Rolling Rollback step re-applies the manifests from the last successful release stored in the cluster release history secret. Harness runs this step automatically when a rolling or canary stage fails. You can also add it manually to a rollback group.

***

### Before you begin <a href="#before-you-begin" id="before-you-begin"></a>

Before you configure the step, make sure you have the following in place:

* **A Kubernetes service:** Go [Kubernetes services](/continuous-delivery/3.0/use-deployments/kubernetes/kubernetes-services.md) to set up service manifests and artifact source.
* **A Kubernetes infrastructure:** Go [Kubernetes infrastructure](/continuous-delivery/3.0/use-deployments/kubernetes/kubernetes-infrastructure.md) to connect your cluster and namespace.
* **A Harness delegate in your target cluster:** The delegate runs deployment steps in your cluster.
* **Runtime configuration:** Every Kubernetes stage requires a `runtime` block specifying connector and namespace. Go [Kubernetes runtime configuration](/continuous-delivery/3.0/use-deployments/kubernetes/overview.md#kubernetes-runtime-configuration) to understand required fields.

***

### Configure the step <a href="#configure-the-step" id="configure-the-step"></a>

The following parameters are available on the Kubernetes Rolling Rollback step.

| Parameter                     | Description                                                                                                                           | Required |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| **Name**                      | Display name for this step. Default: `Kubernetes Rolling Rollback`.                                                                   | Required |
| **Enable Kubernetes Pruning** | When enabled, removes resources from the cluster that are not in the rollback release manifests before re-applying. Default: `false`. | Optional |
| **Kubeconfig Path**           | Path to the kubeconfig file. Default: `${{infra.kube_config_path}}`.                                                                  | Optional |
| **Namespace**                 | Target namespace. Default: `${{infra.namespace}}`.                                                                                    | Optional |
| **Release Name**              | Release name used to look up the rollback target in the cluster secret. Default: `${{infra.releaseName}}`.                            | Optional |

***

### How the step works <a href="#how-the-step-works" id="how-the-step-works"></a>

The step retrieves the previous release manifests from the Harness release history secret stored in the target namespace and re-applies them using `kubectl apply`.

With **Enable Kubernetes Pruning** set to `true`, resources that exist in the current release but not in the rollback release are deleted before the rollback manifests are applied. With it set to `false`, only the apply runs and any extra resources remain in the cluster.

***

### Advanced settings <a href="#advanced-settings" id="advanced-settings"></a>

* **Timeout duration:** Maximum time the step is allowed to run before being terminated.
* **On failure:** Define what happens if the step fails, such as retry, mark as success, or abort.
* **Strategy:** Configure a looping strategy to run this step over a list of values.
* **Conditional execution:** Run this step only when a specified condition is true.

***

### Next steps <a href="#next-steps" id="next-steps"></a>

* Go [Kubernetes rolling deployment](/continuous-delivery/3.0/use-deployments/kubernetes/kubernetes-deployment-strategies/rolling.md) to understand when rollback runs automatically.
* Go [Kubernetes Rolling Deploy](/continuous-delivery/3.0/use-deployments/kubernetes/step-library/k8s-rolling-deploy.md) to review the deploy step reference.
