Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.
BETA

Ephemeral delegate mode

Run containerized step group steps in a short-lived delegate container, in the same Kubernetes cluster as the delegate or in a different one

This feature is in Beta and requires enablement. View all early access features.

Ephemeral delegate mode allows a Harness Delegate to run containerized step group steps in a short-lived delegate container that Harness adds to the step group pod. The pod can run in the same Kubernetes cluster as the delegate or in a different cluster, without installing a delegate there. Use it to run steps such as Git Clone and Run in a separate cluster, while keeping a single delegate to orchestrate them.

A standard delegate runs its work in the cluster where you install it, so running steps elsewhere means installing and maintaining another delegate there. In ephemeral delegate mode, the delegate that you select still orchestrates the step group. Harness adds a short-lived delegate container to the step group pod, which runs the steps. The ephemeral delegate exists only for the step group pod, so when the pod runs in a different cluster, there is nothing to install, upgrade, or monitor in that cluster.


What you will learn from this topic


Before you begin

  • Containerized step groups: Go to Containerize step groups to learn how to configure a step group that uses Kubernetes infrastructure.

  • Delegate: Delegate 1.x version 26.10.90103 or later, or Runner (task runner) version 3.8.0 or later. For more information, see Delegate overview.

  • Target cluster: The Kubernetes cluster where the step group pod runs, which can be the cluster where the delegate runs or a different one. You need a namespace in that cluster and a Harness Kubernetes Cluster connector that can reach it.

  • Network access: The target cluster must be able to reach the Harness control plane and pull the delegate image from us-docker.pkg.dev.

  • Feature flags: Contact Harness Support to enable PIPE_ENABLE_EPHEMERAL_DELEGATE_MODE, PL_USE_TASK_RUNNER, CDS_INIT_CONTAINER_V2_ASYNC_STEP, and CDS_CONTAINER_STEP_GROUP_STEPS_USE_RUNNER. Enabling the feature flag alone is not enough. You must also enable the account, organization, or project setting.

  • Pipeline permissions: You need View, Create/Edit, and Execute on pipelines. For more information, see RBAC in Harness.


Execution flow

When ephemeral delegate mode is enabled, Harness changes how the step group pod is built. The flow has the following stages:

  1. The delegate you select in the step group creates the step group pod in the namespace and cluster defined by the step group's Kubernetes infrastructure.

  2. Harness adds an ephemeral delegate container to that pod, along with an init container, volumes, and a secret that holds the ephemeral delegate configuration.

  3. The task runner in the ephemeral delegate container runs the steps in the step group, such as Git Clone and Run.

  4. When the steps finish, the task runner reports completion.

Running the step group in a different cluster is optional. The delegate that you select can run in the target cluster or in a different cluster. Steps run in ephemeral delegate mode only when the setting and the four feature flags are enabled. When they are enabled, the steps that you can run in a containerized step group or a CI stage are expected to run in this mode.

The ephemeral delegate container adds its own CPU and memory overhead to the pod. The Initialize log lists the total resources for the pod, including this overhead.


Enable ephemeral delegate mode

To enable ephemeral delegate mode, enable the setting and then set the delegate image.

Enable the setting

You can enable the setting at the account, organization, or project scope. The setting is False by default. A project inherits the value from its organization or account unless you override it.

Perform the following steps to enable the setting:

  1. Navigate to Settings -> Default Settings -> Pipeline at the account, organization, or project scope.

  2. Find Enable Ephemeral Delegate Mode.

  3. Select True.

  4. Click Save.

The Enable Ephemeral Delegate Mode setting in the Pipeline settings, set to True and inherited from the account

Set the ephemeral delegate image

Delegate 1.x requires the HARNESS_EPHEMERAL_DELEGATE_IMAGE environment variable. There is no default value, so set it as an environment variable in the delegate Helm values or manifest YAML to the image that Harness adds to the step group pod. If you use the Runner, the variable is optional because the Runner discovers the image automatically.

The following example sets the variable:

The following table describes the variable and the parts of its value:

Parameter
Description

HARNESS_EPHEMERAL_DELEGATE_IMAGE

Environment variable that you set on the Harness Delegate (Delegate 1.x) that orchestrates the step group. Its value is the image that Harness uses for the ephemeral delegate container in the step group pod. Required for Delegate 1.x and optional for the Runner.

us-docker.pkg.dev/gar-prod-setup/harness-public/harness/delegate

Repository path of the Harness delegate image in the public Harness Google Artifact Registry.

3.9.0

Image tag. The example uses 3.9.0. Harness does not set a default tag.

The cluster that runs the step group pod must be able to pull this image. In the Initialize log, the pulled image appears in the container events for the step group pod.


Configure a step group

Ephemeral delegate mode uses the same step group configuration as other containerized step groups. To run the step group in the same cluster as the delegate, select the connector and namespace for that cluster. To run it in a different cluster, select the connector and namespace for the other cluster. In the step group, enable container-based execution and configure the following settings:

  • Infrastructure: Select Kubernetes.

  • Kubernetes cluster: Select the Kubernetes Cluster connector for the target cluster.

  • Namespace: Enter the namespace in the target cluster where Harness creates the pod.

  • Delegate selector: Select the delegate that orchestrates the step group.

The following pipeline runs a Git Clone step and a Run step in the target cluster:

In this example:

  • stepGroupInfra.spec.connectorRef and namespace identify the target cluster and namespace where the step group pod runs.

  • delegateSelectors selects the delegate that orchestrates the step group.

  • The stage environment and infrastructure definition are independent of where the step group runs.


Verify the execution

When the pipeline runs, the Initialize step of the step group shows how Harness builds the pod. A successful run includes log entries similar to the following:

The injected ephemeral delegate topology line confirms that ephemeral delegate mode is active for the step group.


Troubleshooting

The following issues can appear when you run a step group in ephemeral delegate mode.

The Initialize log shows "Namespaces do not match" and uses the default service account

The log message is cannot use current delegate's service account name. Namespaces do not match. It appears when the step group pod's namespace differs from the delegate's namespace. Harness uses the default service account in the target namespace for the pod. No specific service account is required, and the default service account works.

If the steps need additional permissions, create a service account with those permissions in the target namespace and set it in the step group Kubernetes infrastructure. For more information, see Service account name.

The Initialize log shows readiness probe failures with "connection refused"

Lines such as Readiness probe failed ... connection refused can appear while the containers in the pod start. If the log then shows that the pod is ready, no action is needed.

If the pod never becomes ready, check that the cluster can pull the delegate image set in HARNESS_EPHEMERAL_DELEGATE_IMAGE and has outbound access to us-docker.pkg.dev.

The step group does not use ephemeral delegate mode

Check the following:

  • The four feature flags listed under Before you begin are enabled for your account.

  • Enable Ephemeral Delegate Mode is set to True at the scope that applies to the project. The setting must be on in addition to the feature flag.

  • The delegate is Delegate 1.x version 26.10.90103 or later, or Runner 3.8.0 or later.

  • On Delegate 1.x, the HARNESS_EPHEMERAL_DELEGATE_IMAGE environment variable is set on the delegate.

  • The Initialize log contains the injected ephemeral delegate topology line.


Next steps

Last updated

Was this helpful?