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.
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.
To install a Docker delegate with custom certificates, do the following:
Prepare the custom cert file(s).
Mount the file(s) to the
/opt/harness-delegate/ca-bundle/directory inside the delegate container.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.vernoExample: 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:
Create a Kubernetes secret with the custom cert file.
Modify the delegate manifest file to include a volume mount.
Add the following YAML under
spec.template.spec.containers.
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.
Set the security context to provide operator access to the mounted files. Add the following YAML under
spec.template.spec.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:
In the delegate YAML file, mount the certificates in
/ca-bundle.Add the
securityContextto the upgrader cron job.
Create a Kubernetes secret with the custom cert file.
Run the following to set the
delegateCustomCa.secretNamevariable 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:
Create a Kubernetes secret with the custom cert file.
Run the following to set the
upgraderCustomCa.secretNamevariable when you install the Helm chart.This adds your volume mount to the
/ca-bundledirectory.
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:
A certificate for the delegate Java process, which makes connections to external systems.
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.yamlfile and provide it to the delegate Java process.Add a volume mount to the
harness-delegate.yamlfile and configure the delegate container OS to have the certificates.
For information on best practices for truststore creation, go to Java Keystore Best Practices.
Create a custom truststore
Prepare the custom cert file(s).
(Optional) Get a base truststore file from a running delegate instance.
Kubernetes delegate
Docker delegate
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.
Mount the truststore file to the delegate container.
Mount the custom certificates to the
/etc/pki/ca-trust/source/anchors/directory.Run the delegate container with the root user.
Add
update-ca-trusttoINIT_SCRIPT.Example command
Use your custom truststore to create a secret.
Modify the delegate manifest file to include a volume mount.
Add the following YAML under
spec.template.spec.containers.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.
Set the security context to provide operator access to the mounted files. Add the following YAML under
spec.template.spec.Use the root user. This is the default and might not require modifications. Add the following YAML under
spec.template.spec.containers.Update the
JAVA_OPTSenvironment variable with information about your custom truststore. Replace the password placeholder with the password you used in your truststore.
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.
In this example, we'll use cert1.crt and cert2.crt files that have custom certificates.
Mount the certificates to the delegate pod in the
/etc/pki/ca-trust/source/anchors/directory.Run
update-ca-trustusingINIT_SCRIPT.
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?