Skip to main content

Running Harness Delegate on a Read-Only File System

This guide provides detailed instructions on how to configure the Harness Delegate to operate on a read-only file system for both Kubernetes/Helm and Docker deployments.

The Harness Delegate requires write access to specific directories to function correctly. By default, the delegate writes to two key directories:

  • Temporary Directory (default: /tmp)

  • Working Directory (default: /opt/harness-delegate/)

When deploying the delegate on a read-only file system, neither of these two locations is writable, so writable alternatives must be provided for these directories. The most common solution is to mount writable volumes in these locations, /tmp can be mounted directly, but the working directory needs to mount to a non-existing location and configure WORKING_DIR to point to that location.

note

This setup requires specific configurations in both Kubernetes and Docker deployments. If you encounter issues, contact Harness Support for assistance.

Prerequisites

Before configuring the delegate to run on a read-only file system, ensure that you meet the following prerequisites:

  • Delegate Version: You are using a delegate version that supports running on a read-only file system. This functionality is available in versions >= 24.08.83702 and 24.08.83702.minimal.

  • Writable Directories: You have identified the directories that must remain writable, such as /tmp and the working directory.

Configuring the Delegate for a Read-Only File System

Use the steps below to configure the Harness Delegate to run on a read-only file system.

To configure the delegate in a Docker container with a read-only file system, follow these steps:

  1. Mount Writable Volumes:

    The delegate requires writable volumes for the /tmp and working directories. You can mount these volumes as tmpfs to allow writing.

    • /tmp: Mount as a writable volume.

    • Working Directory: Mount a writable volume to a non-existing location and configure the WORKING_DIR environment variable to point to this location.

    Example: Docker Command:

    docker run -d --cpus=1 --memory=2g --read-only \
    --mount type=tmpfs,destination=/writable \
    --mount type=tmpfs,destination=/tmp \
    -e WORKING_DIR="/writable" \
    -e DELEGATE_NAME=docker-delegate-ro \
    -e NEXT_GEN="true" \
    -e DELEGATE_TYPE="DOCKER" \
    -e ACCOUNT_ID=<account_id> \
    -e DELEGATE_TOKEN=<token> \
    -e DELEGATE_TAGS="" \
    -e LOG_STREAMING_SERVICE_URL=https://app.harness.io/log-service/ \
    -e MANAGER_HOST_AND_PORT=https://app.harness.io harness/delegate:24.08.83702.minimal

    Explanation:

    • --read-only: Enables the read-only file system.

    • -e WORKING_DIR="/writable": Configures the working directory for the delegate.

    • --mount type=tmpfs,destination=/writable: Mounts an empty space for the working directory.

    • --mount type=tmpfs,destination=/tmp: Mounts an empty space for the tmp directory.

  2. Set Environment Variables

    Ensure all required environment variables are properly set. This includes:

    • DELEGATE_NAME: The name of your delegate.

    • NEXT_GEN: Set to "true" to enable the next-generation delegate features.

    • ACCOUNT_ID: Your Harness account ID.

    • DELEGATE_TOKEN: Your delegate token for authentication.

    • LOG_STREAMING_SERVICE_URL: The URL for log streaming.

  3. Verify the Deployment

    After running the Docker container, verify that the delegate is functioning correctly:

    • Check the logs using docker logs <container_id>.

    • Ensure there are no permission errors related to the read-only file system.

    • Confirm that the delegate is registered and active in your Harness account.