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

VPN for Harness Cloud

Establish VPN connectivity from Harness Cloud VMs to your private network using OpenVPN or WireGuard.

For teams that need to connect Harness Cloud VMs to on-premises or private cloud resources through a traditional VPN tunnel, Harness supports two VPN solutions:

OpenVPN Establishes a TLS-encrypted tunnel from the Cloud VM to your OpenVPN server. Supports both UDP and TCP, certificate-based and username/password authentication, and enterprise PKI integration.

WireGuard A modern, high-performance VPN that creates an encrypted tunnel using the Noise protocol. Offers faster connection times, higher throughput, and a simpler configuration compared to OpenVPN.

Both solutions run a VPN client directly on the ephemeral Harness Cloud VM, creating a secure tunnel to your VPN server. You store the VPN configuration as a base64-encoded Harness secret and decode it at runtime.

OpenVPN

Architecture

The OpenVPN client runs on the Harness Cloud VM, establishes a TLS-encrypted tunnel over UDP (port 1194) to your OpenVPN server, and creates a tun0 virtual interface. Traffic destined for your private network is routed through this tunnel.

Connection flow:

  1. TLS handshake and certificate exchange

  2. Server validates client certificate

  3. Session keys established via Diffie-Hellman

  4. tun0 interface created (client gets IP like 10.8.0.2)

  5. Routes pushed from server to client

  6. Encrypted data transfer begins

Prerequisites

  • An OpenVPN server accessible from the internet with a public IP or domain

  • A client configuration file (.ovpn) with embedded certificates

  • The .ovpn config stored as a base64-encoded Harness file secret

Setup VPN client in pipeline

Store your .ovpn configuration file as a base64-encoded Harness secret:

Add the following steps to your pipeline stage to establish and verify the VPN connection:

Install and connect

Verify connectivity

Cleanup

WireGuard

Architecture

The WireGuard client runs on the Harness Cloud VM, establishes an encrypted tunnel using the Noise protocol over UDP (port 51820) to your WireGuard server, and creates a wg0 virtual interface. Traffic to your private subnets is routed through this tunnel.

Connection flow:

  1. Client sends encrypted handshake with public key

  2. Server validates client public key and responds

  3. Session established in under 1 RTT

  4. wg0 interface created (client gets IP like 10.0.0.2)

  5. Each packet individually authenticated with replay protection

Prerequisites

  • A WireGuard server accessible from the internet with a public IP or domain

  • A client configuration file (wg0.conf) with keys and peer configuration

  • The wg0.conf config stored as a base64-encoded Harness file secret

Setup VPN client in pipeline

Store your WireGuard configuration as a base64-encoded Harness secret:

Add the following steps to your pipeline stage. WireGuard steps require privileged: true and runAsUser: "0":

Install WireGuard

Configure and connect

Verify connectivity

Cleanup

Tunnel configuration

Split tunneling routes only traffic destined for your private subnets through the VPN. All other traffic (internet, package downloads) uses the default route. This is the recommended approach for CI/CD pipelines.

OpenVPN - Configure on your server:

WireGuard - Configure in wg0.conf:

Full tunnel

Full tunneling routes all traffic through the VPN. Use this when compliance requires complete traffic encryption or when accessing geo-restricted resources.

OpenVPN - Configure on your server:

WireGuard - Configure in wg0.conf:

Best practices

Keep the following in mind when you configure VPN connectivity for Harness Cloud VMs:

  • Store credentials as Harness secrets - Never hardcode VPN keys or certificates in pipeline YAML.

  • Always include cleanup steps - Use when: stageStatus: All to ensure VPN resources are cleaned up even on failure.

  • Verify connectivity before proceeding - Add a verification step after connecting to confirm the VPN is operational.

  • Use split tunneling - Route only necessary traffic through the VPN to minimize latency and bandwidth overhead.

  • Use PersistentKeepalive - Set PersistentKeepalive = 25 in WireGuard configs to prevent NAT timeout issues.

  • Set connection timeouts - Avoid indefinite hangs by implementing timeout logic when waiting for VPN connections.

Next steps

Go to Private network connectivity options to compare VPN connectivity with IP allowlisting and PrivateLink or Private Service Connect.

Last updated

Was this helpful?