> 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/harness-platform/use-harness-platform/delegates/delegate/delegate-reference/delegate-environment-variables.md).

# Delegate environment variables

The following environment variables are available for use in the delegate manifest. Some of these variables are included in the YAML by default; you can specify others based on use case.

#### ACCOUNT\_ID <a href="#accountid" id="accountid"></a>

The Harness account Id of the account with which this delegate registers.

This value is automatically added to the delegate configuration file (the application manifest of a Kubernetes delegate) when you add the delegate.

```yaml
        - name: ACCOUNT_ID
          value: YOUR_ACCOUNT_ID
```

#### DELEGATE\_DESCRIPTION <a href="#delegatedescription" id="delegatedescription"></a>

A text description of the delegate. The description is added to the delegate before registration, in Harness Manager or in YAML. This value is displayed on the delegate details page in Harness Manager.

```yaml
        - name: DELEGATE_DESCRIPTION
          value: ""
```

#### DELEGATE\_NAME <a href="#delegatename" id="delegatename"></a>

The name of the delegate. This is the name that identifies a registered delegate in Harness.

This value is not specified when delegate creation is automated. Instead, a script is used to duplicate the delegate YAML file and add a unique name to the `DELEGATE_NAME` environment variable for each delegate to be registered. Go to [Automate delegate installation](/harness-platform/use-harness-platform/delegates/delegate/install-delegates/automate-delegate-installation.md).

```yaml
        - name: DELEGATE_NAME
          value: qa
```

#### DELEGATE\_NAMESPACE <a href="#delegatenamespace" id="delegatenamespace"></a>

The namespace for the delegate is taken from the `StatefulSet` namespace.

```yaml
        - name: DELEGATE_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
```

#### DELEGATE\_TAGS <a href="#delegatetags" id="delegatetags"></a>

Delegate tags are descriptors that are added to the delegate before the registration process, in Harness Manager or in YAML. Harness generates tags based on the delegate name; you can add others. You can specify multiple tags in YAML as a comma-separated list.

Tags are displayed on the delegate details page in Harness Manager. Go to [Tags reference](/harness-platform/use-harness-platform/tags/overview.md#create-tags-for-pipelines) and [Use delegate selectors](/harness-platform/use-harness-platform/delegates/delegate/manage-delegates/select-delegates-with-selectors.md).

```yaml
        - name: DELEGATE_TAGS
          value: "has_jq, has_gcloud"
```

#### DYNAMIC\_REQUEST\_HANDLING <a href="#dynamicrequesthandling" id="dynamicrequesthandling"></a>

{% hint style="warning" %}
This option is deprecated as of delegate version `26.07.89601`. Please use `DELEGATE_CPU_THRESHOLD`, `DELEGATE_MEMORY_THRESHOLD` and `DELEGATE_CGROUP_MEMORY_THRESHOLD` to configure resource usage limits individually.
{% endhint %}

Dynamic request handling is designed to prevent delegates from being overloaded. Enabling `DYNAMIC_REQUEST_HANDLING` will stop acquiring new tasks if the CPU and Memory default threshold is exceeded. By default, the threshold is set to 80%. You can override this value by configuring the `DELEGATE_CPU_THRESHOLD`, `DELEGATE_MEMORY_THRESHOLD` and `DELEGATE_CGROUP_MEMORY_THRESHOLD` variables.

```yaml
    - name: DYNAMIC_REQUEST_HANDLING
      value: "true"
```

#### DELEGATE\_CPU\_THRESHOLD <a href="#delegatecputhreshold" id="delegatecputhreshold"></a>

To configure the delegate resource threshold, set the `DELEGATE_CPU_THRESHOLD` env variable to the CPU threshold in percentages. When the threshold is exceeded, the delegate rejects new tasks.

```yaml
     - name: DELEGATE_CPU_THRESHOLD
       value: "80"
```

#### DELEGATE\_MEMORY\_THRESHOLD <a href="#delegatememorythreshold" id="delegatememorythreshold"></a>

To configure the delegate resource threshold, set the `DELEGATE_MEMORY_THRESHOLD` env variable to the memory threshold in percentages. This option takes two memory calculations into account:

* JVM memory usage: This is the memory used by the Delegate's process. If the JVM memory usage exceeds the threshold, the delegate rejects new tasks.
* System memory usage: This considers the system memory usage. If the system's memory usage exceeds the threshold, the delegate rejects new tasks.

{% hint style="info" %}
When the `DELEGATE_CGROUP_MEMORY_THRESHOLD` option (see below) is used, the System memory check mentioned here is skipped and is replaced by the cgroup system memory calculation, which is more accurate for systems that are cgroup-compatible.
{% endhint %}

```yaml
     - name: DELEGATE_MEMORY_THRESHOLD
       value: "80"
```

#### DELEGATE\_CGROUP\_MEMORY\_THRESHOLD <a href="#delegatecgroupmemorythreshold" id="delegatecgroupmemorythreshold"></a>

To configure the delegate resource threshold, set the `DELEGATE_CGROUP_MEMORY_THRESHOLD` env variable to the memory threshold in percentages. This is the recommended way for setting system-level memory usage threshold for Delegates running in cgroup compatible environments (Linux, container runtimes or Kubernetes nodes).

```yaml
     - name: DELEGATE_CGROUP_MEMORY_THRESHOLD
       value: "80"
```

#### DELEGATE\_TASK\_CAPACITY <a href="#delegatetaskcapacity" id="delegatetaskcapacity"></a>

Harness enables you to configure a maximum number of tasks for each delegate. This allows Harness Manager to use the task capacity to determine whether to assign a task to the delegate or queue it.

```yaml
        - name: DELEGATE_TASK_CAPACITY
          value: "2"

```

For example, if you set `DELEGATE_TASK_CAPACITY` to a value of 2 and execute 6 tasks in parallel, Harness Manager only executes 2 tasks at a time. If you don't configure `DELEGATE_TASK_CAPACITY`, Harness Manager executes all 6 tasks in parallel.

{% hint style="info" %}
This functionality is currently behind the feature flag `DELEGATE_TASK_CAPACITY_CHECK` and is available for Harness NextGen only. Contact [Harness Support](mailto:support@harness.io) to enable the feature. When the feature flag is enabled, the task is broadcast every minute in Harness Manager until it expires.
{% endhint %}

#### DELEGATE\_TYPE <a href="#delegatetype" id="delegatetype"></a>

The type of the delegate.

```yaml
        - name: DELEGATE_TYPE
          value: "KUBERNETES"
```

#### INIT\_SCRIPT <a href="#initscript" id="initscript"></a>

Used to specify a script that runs when the delegate is initialized. You can use this environment variable to run scripts on the delegate but this is not a best practice. Delegate initialization should be built into the image; not determined on startup.

```yaml
        - name: INIT_SCRIPT
          value: |-
            echo "initializing Delegate"
            echo "Delegate initialized"
```

#### JAVA\_OPTS <a href="#javaopts" id="javaopts"></a>

Use the `JAVA_OPTS` environment variable to add or override JVM parameters. The delegate accepts the following JVM options.

```yaml
        - name: JAVA_OPTS
          value: "-XX:+UseContainerSupport -XX:MaxRAMPercentage=70.0 -XX:MinRAMPercentage=40.0 -XX:+HeapDumpOnOutOfMemoryError"
```

#### MANAGER\_HOST\_AND\_PORT <a href="#managerhostandport" id="managerhostandport"></a>

The Harness SaaS manager URL. The specification of HTTPS in the URL indicates the use of port 443.

```yaml
        - name: MANAGER_HOST_AND_PORT
          value: https://app.harness.io
```

#### NEXT\_GEN <a href="#nextgen" id="nextgen"></a>

Whether the delegate is registers in Harness NextGen or FirstGen. A value of `true` indicates that the delegate registers in Harness NextGen; a value of `false` indicates that the delegate registers in FirstGen.

```yaml
        - name: NEXT_GEN
          value: "true"
```

#### POLL\_FOR\_TASKS <a href="#pollfortasks" id="pollfortasks"></a>

Enables or disables polling for delegate tasks. By default, the delegate uses Secure WebSocket (WSS) for tasks. If the `PROXY\_\*` settings are used and the proxy or some intermediary does not allow WSS, then set `POLL\_FOR\_TASKS` to true to enable polling.

```yaml
        - name: POLL_FOR_TASKS
          value: "false"
```

#### STACK\_DRIVER\_LOGGING\_ENABLED <a href="#stackdriverloggingenabled" id="stackdriverloggingenabled"></a>

Delegates send logs to Harness by default. Harness uses these logs for debugging and support. To disable this functionality, set this value to "false".

```yaml
        - name: STACK_DRIVER_LOGGING_ENABLED
          value: "false"
```

#### PROXY\_\* <a href="#proxy" id="proxy"></a>

You can use delegate proxy settings to change how the delegate connects to Harness Manager.

The `secretKeyRef` values are named based on delegate name.

```yaml
        - name: PROXY_HOST
          value: ""
        - name: PROXY_PORT
          value: ""
        - name: PROXY_SCHEME
          value: ""
        - name: NO_PROXY
          value: ""
        - name: PROXY_MANAGER
          value: "true"
        - name: PROXY_USER
          valueFrom:
            secretKeyRef:
              name: mydel-proxy
              key: PROXY_USER
        - name: PROXY_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mydel-proxy
              key: PROXY_PASSWORD
```
