> 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-blue-green-stage-scale-down.md).

# Kubernetes Blue Green Stage Scale Down

The Kubernetes Blue Green Stage Scale Down step removes the old pod set after a successful blue-green swap. Add it after the Swap Services Selectors step when you want to free cluster resources once you are confident the new version is stable.

***

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

***

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

The following parameters are available on the Kubernetes Blue Green Stage Scale Down step.

| Parameter           | Description                                                                                        | Required |
| ------------------- | -------------------------------------------------------------------------------------------------- | -------- |
| **Name**            | Display name for this step in the stage canvas. Default: `Kubernetes Blue Green Stage Scale Down`. | Required |
| **Kubeconfig Path** | Path to the kubeconfig file. Default: `${{infra.kube_config_path}}`.                               | Optional |
| **Namespace**       | Target namespace. Default: `${{infra.namespace}}`.                                                 | Optional |
| **Release Name**    | Name used to look up the release history for the old pod set. Default: `${{infra.releaseName}}`.   | Optional |
| **Log Level**       | Verbosity of step logs. Default: `info`.                                                           | Optional |

{% hint style="warning" %}
**RELEASE NAME MUST BE UNIQUE PER NAMESPACE**

When deploying multiple services to the same namespace using blue-green, each service must have a unique release name. If multiple services share the same release name, the Scale Down step may incorrectly identify which deployment to scale down.
{% endhint %}

***

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

The step removes the following resources for the old (inactive) pod set:

* HorizontalPodAutoscaler and PodDisruptionBudget resources
* Deployments, DeploymentConfigs, and StatefulSets
* DaemonSets (scaled to zero replicas)

{% hint style="info" %}
**RESOURCES ARE DELETED, NOT SCALED TO ZERO**

The Scale Down step deletes workload resources rather than setting replicas to zero. This prevents HPA from overriding a zero-replica state on subsequent deployments. HPA and PDB resources deleted during Scale Down are not recreated during rollback; they require redeployment to restore.
{% endhint %}

***

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

* **Timeout duration:** Maximum time the step can run before Harness terminates it.
* **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 to [Kubernetes blue-green deployment](/continuous-delivery/3.0/use-deployments/kubernetes/kubernetes-deployment-strategies/blue-green.md) to understand when to use this step in the blue-green flow.
* Go to [Kubernetes Blue Green Swap Services Selectors](/continuous-delivery/3.0/use-deployments/kubernetes/step-library/k8s-blue-green-swap-services.md) to configure the step that routes production traffic before scale-down.
