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

Integrate Self-Managed Enterprise Edition with HashiCorp Vault

Learn how to integrate Harness SMP with HashiCorp Vault to securely inject secrets at runtime without storing them as Kubernetes Secrets.

Overview

This guide explains how to configure a self-managed Harness platform to source Harness service secrets directly from HashiCorp Vault, instead of storing them as Kubernetes Secrets.

Key benefits

  • Eliminate Kubernetes Secrets: Secrets are never stored in kubernetes secrets, avoiding the risk of secrets being exposed through commands such as kubectl get secrets.

  • Fetch secrets at runtime: Secrets are retrieved from Vault when pods start and are made available to application containers before execution.

  • Centralize secret management: Continue using your existing Vault instance, policies, and workflows without duplicating secrets in Kubernetes.

How the integration works

The integration operates in two stages:

  • One-time setup: You run a command-line tool that reads your Harness Helm chart and automatically creates the required secrets in your Vault instance.

  • Runtime behavior: When Harness pods start, an init container authenticates with Vault, fetches the secrets required by that pod, and makes them available to the application container before it starts.

Supported Modules

  • CI

  • CD

  • Chaos


Prerequisites

Before you start, make sure you have the following in place:

  • A running HashiCorp Vault instance, either inside the Kubernetes cluster or on an external server with network access to the Kubernetes API

  • A Vault token with the necessary permissions to create and read secrets

  • The Harness Helm chart and its associated override values file


Configure HashiCorp Vault

Before generating secrets, you need to configure HashiCorp Vault with the required secret engine, policies, and authentication method.

Step 1. Enable the Key-Value Version 2 secrets engine

This setup also works with the KV v1 secrets engine. If KV v1 is already enabled at the desired path, no additional changes are required.

Enable the KV v2 secrets engine at the harness-engine/ path by running the following command:

Step 2. Create a generator policy and token

The secrets generator requires a Vault token with permission to write secrets. Start by creating a policy file named harness-generator-policy.hcl:

Apply the policy and generate a token:

Store this token securely. You will need it later when running the generator tool.

Step 3. Configure Kubernetes authentication

For production environments, configure Kubernetes authentication so that Harness pods can securely authenticate with Vault at runtime.

3.1 Enable Kubernetes authentication

3.2 Configure the Kubernetes auth method

Choose the configuration based on where your Vault instance runs.

Option A: Vault runs inside the Kubernetes cluster

When Vault runs as a pod in the same cluster, it auto-discovers the Kubernetes CA certificate and service account token from the pod's filesystem.

Option B: Vault runs outside the Kubernetes cluster

When Vault runs on an external VM or server, set disable_local_ca_jwt=true so that Vault uses each client's service account token for TokenReview validation.

Replace <kubernetes-api-endpoint> with your cluster's API server address.

NETWORK ACCESS REQUIRED

Ensure the Vault server can reach the Kubernetes API endpoint on port 443. For GKE clusters with authorized networks enabled, add the Vault server's IP to the authorized networks list. For EKS or AKS, verify that security groups or network security rules allow traffic from the Vault server to the API server on port 443.

If your cluster API server does not have publicly trusted TLS certificates (for example, self-managed clusters using kubeadm, k3s, or RKE), provide the cluster CA certificate by setting kubernetes_ca_cert in the Vault Kubernetes auth config.

Since disable_local_ca_jwt=true causes Vault to use each client's own service account token for TokenReview, all Harness service accounts that authenticate with Vault must have the system:auth-delegator ClusterRole:

Add service accounts for optional modules (such as Chaos) as listed in step 3.4.

3.3 Create a runtime policy

Create a read-only policy file named harness-runtime-policy.hcl. This policy allows Harness pods to read secrets from Vault at runtime.

Apply the policy:

3.4 Create a Kubernetes auth role for Harness

Create a Kubernetes auth role that allows Harness pods running in the harness namespace to authenticate with Vault and read secrets during startup:

IMPORTANT: REQUIRED SERVICE ACCOUNTS

Add the following Kubernetes service accounts to the role based on the modules you are installing. CI/CD uses the harness-default service account.

Platform module (mandatory):

  • harness-looker

  • harness-manager

  • harness-platform-service

  • harness-queue-service

  • harness-serviceaccount

  • ng-manager

  • template-service

Chaos module:

  • chaos-linux-ifc-sa

  • chaos-linux-ifs-sa

  • chaos-machine-ifc-sa

  • chaos-machine-ifs-sa

Set up Vault-backed secrets for Harness SMP

In the previous steps, you configured HashiCorp Vault with the required secrets engine, policies, and authentication methods. With Vault now ready, you can generate the secrets required by Harness SMP and configure Harness to retrieve them directly from Vault at runtime.

This section walks you through generating those secrets and updating your Harness configuration accordingly.

Step 1: Download the secrets generator tool

First, fetch the latest version:

VIEW ALL AVAILABLE VERSIONS

To see all available versions:

Then download the binary that matches your operating system and architecture:

Linux (AMD64)

Linux (ARM64)

macOS (AMD64)

macOS (ARM64 / Apple Silicon)

Windows (AMD64)

Windows (ARM64)


Step 2: Prepare your Vault environment

Before proceeding, verify that the following Vault configuration steps from the prerequisites are complete:

  • A generator token with write permissions has been created

  • Runtime authentication with read permission is configured (Kubernetes authentication is recommended)


Step 3: Configure the Vault connection for the generator

The secrets generator reads Vault connection details from environment variables. Set the following environment variables:


Step 4: Generate Harness secrets in Vault

Export the generator token and run the secrets generator:

This command reads the configuration from override.yaml, scans the Harness Helm chart for required secrets (such as database credentials, API keys, and certificates), generates secure secret values, and uploads the secrets to Vault under the harness-engine/harness/* path.

Step 5: Add required secrets to Vault

Before proceeding, manually add the following secrets to your Vault instance under the appropriate paths:

  1. Add license-related secrets

Vault Path
Description

<engine>/<basePath>/looker/env-secrets/LICENSE_FILE

Looker license file

<engine>/<basePath>/looker/env-secrets/LICENSE_KEY

Looker license key

<engine>/<basePath>/harness-manager/env-secrets/LICENSE_INFO

CG license key

<engine>/<basePath>/ng-manager/env-secrets/SMP_LICENSE

NG license key

2. Add log service storage credentials

Vault Path
Description

<engine>/<basePath>/log-service/env-secrets/LOG_SERVICE_S3_ACCESS_KEY_ID

Access key for S3-compatible storage

<engine>/<basePath>/log-service/env-secrets/LOG_SERVICE_S3_SECRET_ACCESS_KEY

Secret access key for S3-compatible storage

These credentials apply to both AWS S3 and external S3-compatible storage such as MinIO.

3. Verify paths and permissions

  • Ensure all secret paths match the configured engine and base path.

  • Confirm Vault policies allow the Harness services to read these secrets.


Step 5: Configure Vault authentication for Harness

Update override.yaml to match the authentication method to be used by the Harness pods.

1: Kubernetes authentication (recommended)

2. Token authentication (not recommended for production)


Step 6: Configure Database Secrets

1. Database Credentials

Databases (mongoDB, redis, postgres etc.) has to be managed externally or self-managed as harness SMP internal databases need to create DB secrets in kubernetes.

1.1 Static Credentials (Recommended for External Database Providers)

For external databases, customers can choose to use static credentials stored in Vault’s KV secrets engine.

  • Setup: Customers must manually create and manage the database credentials in their Vault instance.

    Example paths:

    Username Paths
    Password Paths

    <engine>/<basePath>/mongo/username

    <engine>/<basePath>/mongo/password

    <engine>/<basePath>/redis/username

    <engine>/<basePath>/redis/password

    <engine>/<basePath>/postgres/username

    <engine>/<basePath>/postgres/password

  • Configuration: Customers must explicitly override the Vault path in values.yaml to point to the location where the static credentials are stored.

    Example configuration:

  • Behavior: At runtime, the secrets loader fetches credentials from the user-provided Vault KV path.

1.2 Dynamic Credentials (Recommended for Self Hosted External Databases)

For internal databases managed by Harness, database credentials are automatically generated and managed by Harness. No manual Vault configuration or overrides are required.


2. Database SSL Certificates (Optional)

If your databases require SSL/TLS, the generator can also help manage the necessary certificates. Before running the generator, add the following section to your override.yaml:

Certificate handling behavior

  • During secret generation, the tool checks harness-engine/harness/{dbType} for the required certificate keys. If any are missing, it provides instructions for uploading the certificates to Vault.

  • At runtime, the loader retrieves the certificates from Vault and mounts them into the application container.


Step 7: Deploy Harness

Deploy or upgrade Harness using the updated override file:


Step 8: Verify the Integration

Verify that all pods have successfully transitioned to the Running state:


Updating secrets and rotation

Secrets are injected into pods only at startup through an init container. As a result, changes made to secrets in Vault are not automatically reflected in running pods. To apply updated values, you must restart the affected pods. This ensures that the pods use the latest values from Vault.

1. Manual secret updates (static secrets)

If you manually update a secret in Vault, for example, when rotating an API key or updating a certificate, you must restart the relevant pods so they can retrieve the new values.

Step 1: Update the secret in Vault

Step 2: Restart the pods

Trigger a rollout restart so the init container runs again and fetches the updated secrets. Restart a specific deployment:

Restart all deployments in the namespace (for example, if a shared secret was updated):


2. Dynamic database credentials (TTL expiry)

When using dynamic database credentials through the Vault database secrets engine, credentials are issued with a defined time-to-live (TTL).

  • Behavior: Vault generates database credentials that are valid for the configured TTL (for example, 24 hours).

  • Expiry: Once the TTL expires, the credentials become invalid and the application loses database connectivity.

  • Rotation: To rotate credentials, the pod must be restarted before the TTL expires so that new credentials can be fetched.

IMPORTANT

Any updates to these secrets must be managed by the customer. Harness does not currently support automatic restarts or secret change watchers.


Advanced configuration

Generator tool options

The vaultSecretGenerator tool supports the following command format:

Required arguments

  • <release-name>: Name of your Harness release (for example, harness)

  • <chart-path>: Path to the Harness Helm chart directory

  • -f <values-file>: Override values file (can be specified multiple times)

Environment variables

  • VAULT_TOKEN: Vault token with write permissions (required)

Optional flags

  • --input-json <file>: Path to a JSON file containing pre-generated secrets. When specified, secret generation is skipped and existing secrets are uploaded to Vault.

  • --output-json <file>: Saves generated secrets to a JSON file for backup or migration purposes.

    Vault connection details—including the address, engine, base path, and authentication method—are read from override.yaml under global.externalSecretsLoader.vault, not from command-line flags.

Example

  1. Basic usage

  2. Using multiple override files


How secrets are organized in Vault

The Harness secrets generator stores secrets in Vault using a predictable path structure, making it easier to manage, audit, and troubleshoot secrets across services.

Secret type
Vault path
Example
Description

Environment variables

harness-engine/harness/{service}/env-secrets

harness-engine/harness/platform-service/env-secrets

Key-value pairs injected into the container as environment variables

File-based secrets

harness-engine/harness/{service}/file-secrets

harness-engine/harness/gateway/file-secrets

File-based secrets such as SSL certificates and JKS keystores

Database credentials

harness-engine/harness/{db-name}

harness-engine/harness/timescaledb

Static database credentials (when not using dynamic secrets)


Configuration options

The following example shows all supported configuration options for using Vault-backed secrets with Harness. This configuration is required to load secrets from Vault at runtime.

You can configure the following options in your override.yaml file:

How secrets are loaded

When a pod starts, an init container is responsible for retrieving secrets from Vault and making them available to the application container. The process follows these steps:

  1. Authenticate to Vault: The init container authenticates to Vault using the configured authentication method.

  2. Fetch environment variable secrets: The init container fetches environment variable secrets from harness-engine/harness/{service}/env-secrets.

  3. Fetch file-based secrets: The init container fetches file-based secrets from harness-engine/harness/{service}/file-secrets.

  4. Generate database credentials: If the database secrets engine is enabled, the init container generates database credentials from database/creds/{role}.

  5. Write secrets to a shared volume: The init container writes secrets to a shared volume:

    • Environment variables are written to /opt/harness/secrets/.env.

    • File-based secrets are written to /opt/harness/secrets/files/{filename}.

  6. Exit successfully: The init container exits successfully, allowing the main application container to start.


File type detection

The secrets loader automatically detects file-based secrets based on their file extensions. Detected files are written to /opt/harness/secrets/files/ with permissions set to 0600 (read/write access for the owner, no access for group or others) and owned by the root user and group. Supported file extensions include .crt, .pem, .key, .jks, and .p12.


Troubleshooting

This section covers common issues you may encounter when using Vault-backed secrets with Harness and how to resolve them.

Common init container issues

Error or symptom
Likely cause
Solution

Permission denied

Vault policy or role misconfiguration

Check the secrets loader logs. Verify that the Vault policy allows read access on harness-engine/data/... and list access on harness-engine/metadata/.... Also confirm the Kubernetes auth role and service account bindings are correct.

Secret not found

Secret missing or incorrect Vault path

Verify that the secret exists in Vault. Re-run the secrets generator if needed. Ensure the service name matches the expected Vault path.

Connection refused or no such host

Network or configuration issue

Confirm that the Vault service is running and reachable. Check the vault.address value in override.yaml. Test connectivity using curl from within the cluster if possible.

Pod stuck in Init:0/1

Any of the above issues

Inspect the init container logs using kubectl logs <pod> -c secrets-loader. Review pod events with kubectl describe pod <pod>.


Frequently asked questions

1. Can I use this integration with secret managers other than Vault?

2. What happens if Vault is unavailable when a pod restarts?

3. How do I update a secret after deployment?

4. What is the minimum Harness Helm chart version required?

The external secrets loader requires Harness Helm chart version 0.36.0 or later.

Last updated

Was this helpful?