> 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/use-continuous-delivery/cd-building-blocks/environments/service-overrides.md).

# Override services at the environment level

Override service settings, such as manifests, config files, and variables, at the environment level or for specific services

In DevOps, it is common to have multiple environments, such as development, testing, staging, and production. Each environment might require different configurations or settings for the same service. For example, in the development environment, a service may need to use a local database for testing, while in the production environment, it should use a high-availability database cluster.

To enable the same service to use different environment settings, DevOps teams can override service settings for each environment.

This topic explains what service settings can be overridden by environments.

***

## What you will learn from this topic

* Understand the [limitations](#limitations) of service overrides.
* Understand which [override types](#override-types) are available for manifests, values YAML, config files, and variables.
* Understand the [override methods](#override-methods) for all services or for specific services.
* Understand the [override priority](#override-priority) among environment service overrides, environment configuration, and service settings.

***

## Limitations <a href="#limitations" id="limitations"></a>

The following limitation applies to service overrides:

* Runtime inputs are not supported if you are trying to override services in multi-service and multi-environment setups.

***

## Override types <a href="#override-types" id="override-types"></a>

The following tabs describe the settings you can override and how each type of override behaves.

{% tabs %}
{% tab title="Manifests" %}
You can override the following manifest types.

![Environment service override showing the manifest override types](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-640eff61522a76995db3cb7a502a522bcda4e2e6%2Fmanifest-override.png?alt=media)

* Values YAML
* OpenShift Param
* Kustomize
* Helm Repo
* ECS Task Definition
* ECS Service Definition
* ECS Scalable Target
* ECS Scaling Policy
* Tanzu Application Service (TAS) manifest
* TAS vars
* TAS AutoScalar

**Notes**

The following notes apply to Helm Repo overrides:

* Helm Repo:
  * You can only override Helm Repo for HTTP Helm, GCS, S3, and OCI store types.
  * Unlike other overrides, you can only override the Harness connector used for Helm Repo. Consequently, when you override the Helm Repo for a service, you must select the same store type used in the service. So, if the service uses HTTP Helm as the store type, the environment override must also use HTTP Helm as the store type. If you select a different store type, Harness throws an exception during execution.
    {% endtab %}

{% tab title="Values YAML" %}
You can specify values YAML files at the environment's **Service Overrides** and **Configuration**, and the service itself.

Here is an example of specifying it at the environment's **Configuration**:

![Values YAML specified in the environment Configuration](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-c59eec2359bef13a070cc69a3213108ffb3ab3f7%2Fservices-and-environments-overview-17.png?alt=media\&token=e5081d8a-f790-4563-91f5-088715dbf9d3)

When you have a values YAML file at two or more of the environment **Service Overrides**, **Environment Configuration**, and the service itself, Harness merges the files into a single values YAML for deployment. This merging is performed at pipeline execution runtime.

{% hint style="info" %}
**LIMITATION**

You cannot check the parametrized values in the values YAML. However, you can view these values in the pipeline execution console view for any deployment type under the Initialize section, when referencing the values YAML in the corresponding manifest.

<img src="https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-ec876c40d86fd6556573b2a0652c0623df0e2334%2Fvalues-yaml-parametrized-values.png?alt=media" alt="Parametrized values shown in the pipeline execution console view" data-size="original">
{% endhint %}

Overriding occurs when the higher priority setting has the same `name:value` pair as a lower priority setting.

The following two examples show how Harness merges values YAML files and how a higher priority values YAML fully overrides a lower priority one.

**Merging values YAML name:value pairs**

An environment's **Service Overrides** values YAML has the name:value pair `servicePort: 80` but no `replicas` name:value.

A service's **Service Definition** has a values YAML with `replicas: 2` but no `servicePort` name:value.

At runtime, the two values YAML files are merged into one.

The `servicePort: 80` from the environment **Service Overrides** values YAML is merged with the **Service Definition**'s `replicas: 2` in the values YAML:

![Environment Service Overrides values YAML merged with the Service Definition values YAML](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-1afdc3b50f15f770f43090615e6154a4de70771d%2Fservice-override.png?alt=media\&token=c24f3f30-13e6-4481-b9a9-7756915947ed)

**Fully overriding values YAML name:value pairs**

An environment's **Service Overrides** values YAML has the name:value pairs `replicas: 2` and `servicePort: 80`.

A service's **Service Definition** has a values YAML with `replicas: 4` and `servicePort: 8080`.

At runtime, the name:value pairs from the environment **Service Overrides** values YAML fully override the service values YAML. The `replicas: 2` and `servicePort: 80` from the environment **Service Overrides** are used.

![Environment Service Overrides values YAML fully overriding the service values YAML](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-171959ae0afef4b39e93dc4eae3c5fb90ffa284b%2Fservice-override2.png?alt=media\&token=9ac4fab5-92e7-4092-93e8-c11a4d74f485)
{% endtab %}

{% tab title="Config files and Variables" %}
Config files and variables are completely overridden.

Config files are a black box that can contain multiple formats and content, such as YAML, JSON, and plain text. Consequently, they cannot be overridden like values YAML files.

Variables cannot be partially overridden either. They are completely replaced.

When you have **Config files** at two or more of the environment **Service Overrides**, **Configuration**, and the service itself, the standard override priority is applied.

When you have **Variables** with the same name at two or more of the environment **Service Overrides**, **Configuration**, and the service itself, the standard override priority is applied.

The following example shows how to configure an override variable and reference it in a pipeline.

**Navigate to Overrides**

* Go to **Project Settings**, **Organization Settings**, or **Account Settings**, depending on the scope of the override. Under **Resources**, click **Overrides**.

**Create a new override**

* Click **New Override** to create a new configuration under the desired scope.
* Under the **Override Type** dropdown, select **Variable**.
* Provide the following details:
  * **VARIABLE NAME**: Enter the variable name (for example, `timeout`).
  * **VARIABLE TYPE**: Select the appropriate type (for example, `String`).
  * **OVERRIDE VALUE**: Enter the desired value (for example, `3m`).

Save the override.

**Reference the variable in the pipeline YAML**

Navigate to the Pipeline you wish to modify and edit the YAML. Locate the section where the variable is defined. Replace the hardcoded value with the variable reference: `variable_identifier: <+serviceVariables.Variable_Name>` Save the YAML.

**Example: Set a timeout override**

If you want to create an override for timeout and set its value to 3 minutes:

Create an override with **Override Value** set to `3m`.

![Variable override with the Override Value set to 3m](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-591b75d49dc9e8a436ade3e926f08376b01a1e1f%2Foverrides_variable.png?alt=media)

Reference it in the pipeline YAML as follows:

```yaml
execution:
            steps:
              - step:
                  name: Stage Deployment
                  identifier: stageDeployment
                  type: K8sBlueGreenDeploy
                  timeout: <+serviceVariables.timeout>
```

When the pipeline runs, the timeout value resolves to 3m, ensuring consistency with the override configuration.
{% endtab %}
{% endtabs %}

***

## Override methods <a href="#override-methods" id="override-methods"></a>

In an environment, you can override one or more settings for **all services** that use the environment and you can override settings for **specific services** that use the environment. The following tabs describe each method.

{% tabs %}
{% tab title="Override all services" %}
In the environment **Configuration**, you can also set the default manifests, config files, and variables to use whenever Harness deploys a service to this environment.

![Default manifests, config files, and variables in the environment Configuration](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-7f4cc09651a875e7c6d5c83c9ace314cb3f38756%2Fservices-and-environments-overview-15.png?alt=media\&token=fbbe4bb8-c8ef-4d96-90d0-38d23acdfc3b)

For example, a stage has a Kubernetes service with a manifest but whenever that service is deployed to the **QA** environment, the manifest in that environment's **Configuration** overwrites the namespace in the service's manifest with `QA`.
{% endtab %}

{% tab title="Override specific services" %}
**Service Overrides** is different from **Configuration** in the following ways:

* Environment **Configuration**: applies to every service that is used with the environment.
* Environment **Service Overrides**: applies to specific services you select. Whenever that service is used with that environment, the **Service Override** is applied.

Perform the following steps to override a specific service's setting:

1. In the environment, select **Service Overrides**.
2. Select **New configuration overrides**.
3. In **Add Override**, select the service.
4. In **Override Type**, select what type of setting you want to override.
5. Select **New Variable/Manifest/Config File Override**.
6. Override the setting.
   {% endtab %}
   {% endtabs %}

***

## Override priority <a href="#override-priority" id="override-priority"></a>

When you use environment configuration and service overrides to override service settings, the priority of the overrides determines which value Harness uses.

The priority from top to bottom is:

1. Environment **Service Overrides**.
2. Environment **Configuration**.
3. Service settings.

![Override priority order from environment Service Overrides to environment Configuration to service settings](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-3134d36d5cbed67776d8874fe6a61a188d02ca62%2Foverride-priority.png?alt=media\&token=de2b9716-d4b1-4abe-b321-3981c530fe91)

{% @harness-feedback/feedback %}
