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

Install delegates with custom certificates

Learn how to install Kubernetes, Docker, and Helm delegates with custom certificates for secure enterprise environments.

This topic explains how to install Kubernetes, Docker, and Helm delegates with custom certificates.

CAUTION

The installation steps are different depending on your delegate version.

If your delegate with an immutable image type version is later than 81202 (image tag 23.10.81202), go to Install with custom certificates.

If your delegate with an immutable image type version is earlier than 81202 (image tag 23.10.81202), go to Install with custom truststore.

For information on delegate types, go to Delegate image types.

Install with custom certificates

Use the steps below to install custom certificates for a Docker, Kubernetes, or Helm delegate with an immutable image type version later than 23.10.81202.

NOTE

Certificates must be PEM format.

To install a Docker delegate with custom certificates, do the following:

  1. Prepare the custom cert file(s).

  2. Mount the file(s) to the /opt/harness-delegate/ca-bundle/ directory inside the delegate container.

  3. Start the delegate with the root user.

    Example: Mount custom certs from a folder

    docker run --cpus=1 -u root --memory=2g \
      -v PUT_YOUR_PATH_TO_FOLDER_OF_CUSTOM_CERTS:/opt/harness-delegate/ca-bundle \
      -e DELEGATE_NAME=PUT_YOUR_DELEGATE_NAME \
      -e NEXT_GEN="true" \
      -e DELEGATE_TYPE="DOCKER" \
      -e ACCOUNT_ID=PUT_YOUR_HARNESS_ACCOUNTID_HERE \
      -e DELEGATE_TOKEN=PUT_YOUR_HARNESS_ACCOUNTID_HERE \
      -e MANAGER_HOST_AND_PORT=PUT_YOUR_MANAGER_HOST_AND_PORT_HERE  harness/delegate:yy.mm.verno

    Example: Mount a single custom cert or a CA bundle file

    docker run --cpus=1 -u root --memory=2g \
      -v PUT_YOUR_PATH_TO_CUSTOM_CERT:/opt/harness-delegate/ca-bundle/abc.pem \
      -e DELEGATE_NAME=PUT_YOUR_DELEGATE_NAME \
      -e NEXT_GEN="true" \
      -e DELEGATE_TYPE="DOCKER" \
      -e ACCOUNT_ID=PUT_YOUR_HARNESS_ACCOUNTID_HERE \
      -e DELEGATE_TOKEN=PUT_YOUR_HARNESS_ACCOUNTID_HERE \
      -e MANAGER_HOST_AND_PORT=PUT_YOUR_MANAGER_HOST_AND_PORT_HERE  harness/delegate:yy.mm.verno

To install a Kubernetes delegate with custom certificates, do the following:

  1. Create a Kubernetes secret with the custom cert file.

    NOTE

    You can install multiple certificates by adding additional --from-file arguments. For example:

  2. Modify the delegate manifest file to include a volume mount.

    1. Add the following YAML under spec.template.spec.containers.

    1. Add the following YAML under spec.template.spec. Replace <YOUR_SECRET_NAME> with the value you used when you created the secret in step 1.

  3. Set the security context to provide operator access to the mounted files. Add the following YAML under spec.template.spec.

  4. Use the root user. This is the default and might not require modification. Add the following YAML under spec.template.spec.containers.

Kubernetes delegate with custom certificates YAML example

Add self-signed certificates to delegate upgrader

For Kubernetes delegates, Harness supports self-signed certificates for delegate upgrader. For more information on delegate upgrades, go to Delegate automatic upgrades and expiration policy.

To add self-signed certificates for delegate upgrader, do the following:

  1. In the delegate YAML file, mount the certificates in /ca-bundle.

  2. Add the securityContext to the upgrader cron job.

  1. Create a Kubernetes secret with the custom cert file.

    NOTE

    You can install multiple certificates by adding additional --from-file arguments. For example:

  2. Run the following to set the delegateCustomCa.secretName variable when you install the Helm chart.

    This adds your volume mount to the /opt/harness-delegate/ca-bundle/ directory.

Add self-signed certificates to delegate upgrader

For Helm delegates, Harness supports self-signed certificates for delegate upgrader. For more information on delegate upgrades, go to Delegate automatic upgrades and expiration policy.

To add self-signed certificates for delegate upgrader, do the following:

  1. Create a Kubernetes secret with the custom cert file.

  2. Run the following to set the upgraderCustomCa.secretName variable when you install the Helm chart.

    This adds your volume mount to the /ca-bundle directory.

Install with custom truststore

Harness Delegate ships with a Java Runtime Environment (JRE) that includes a default trusted certificate in its truststore located in the /opt/java/openjdk/lib/security/cacerts directory. This truststore uses multiple trusted certificates. You can limit the number you use based on your company's security protocols.

The JRE truststore must include the certificate that delegates require to establish trust with Harness (app.harness.io).

Command-line tools use truststore from the underlying Red Hat operating system.

Use the steps below to install custom certificates for a Docker or Kubernetes delegate with an immutable image type version earlier than 23.10.81202.

There are two aspects of custom certificates:

  1. A certificate for the delegate Java process, which makes connections to external systems.

  2. A certificate for the OS itself. With this certificate, if another process, such as a shell script, is spawned, it can access custom certificates.

In this topic, we will do the following:

  • Create a custom truststore.

  • Create a secret.

  • Add a volume mount to the harness-delegate.yaml file and provide it to the delegate Java process.

  • Add a volume mount to the harness-delegate.yaml file and configure the delegate container OS to have the certificates.

Harness recommends that you keep your existing Java KeyStore in place during the installation process. Updating the KeyStore might cause issues with your delegate.

For information on best practices for truststore creation, go to Java Keystore Best Practices.

Create a custom truststore

  1. Prepare the custom cert file(s).

    NOTE

    Certificates must be PEM format.

  2. (Optional) Get a base truststore file from a running delegate instance.

    Kubernetes delegate

    Docker delegate

  3. Import custom certs into the Java truststore.

    a. Split the certificates into individual files if the custom cert file contains multiple certificates.

    b. Run the keytool command below for each certificate file to import them.

    c. Replace the password placeholder with the password you gave your truststore.

    d. Use a unique alias for all imports.

Install truststore and custom certs

After you configure the truststore file and custom certificates, you're ready to install them in a Kubernetes or Docker delegate.

  1. Mount the truststore file to the delegate container.

  2. Mount the custom certificates to the /etc/pki/ca-trust/source/anchors/ directory.

  3. Run the delegate container with the root user.

  4. Add update-ca-trust to INIT_SCRIPT.

    Example command

  1. Use your custom truststore to create a secret.

  2. Modify the delegate manifest file to include a volume mount.

    1. Add the following YAML under spec.template.spec.containers.

    2. Add the following YAML under spec.template.spec. Replace <YOUR_SECRET_NAME> with the value you used when you created the secret in step 1.

  3. Set the security context to provide operator access to the mounted files. Add the following YAML under spec.template.spec.

  4. Use the root user. This is the default and might not require modifications. Add the following YAML under spec.template.spec.containers.

  5. Update the JAVA_OPTS environment variable with information about your custom truststore. Replace the password placeholder with the password you used in your truststore.

    NOTE

    You can omit the specification of the JAVA_OPTS environment variable if you mount the secret to the same location as the default truststore and give it the same name. The JVM then applies the change automatically.

Add custom certificates to the delegate pod

You can add certificates to the delegate pod so any command running on the pod has certificates installed.

NOTE

This step isn't necessary if you don't intend to run commands directly on the pod that needs certificates to connect to external systems.

In this example, we'll use cert1.crt and cert2.crt files that have custom certificates.

  1. Mount the certificates to the delegate pod in the /etc/pki/ca-trust/source/anchors/ directory.

  2. Run update-ca-trust using INIT_SCRIPT.

    NOTE

    The delegate must be the root user.

Kubernetes delegate with truststore YAML example

The following example harness-delegate.yaml file includes the changes required to install a delegate with a custom certificate.

Last updated

Was this helpful?