Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
K

kubevpn

> DevOps
Open source

KubeVPN offers a Cloud Native Dev Environment that connects to kubernetes cluster network.

1.4K stars0 likes1 views
WebsiteGitHub

About

KubeVPN offers a Cloud Native Dev Environment that connects to kubernetes cluster network.

![GitHub Workflow][1] Go Version Go Report Maintainability GitHub License Docker Pulls Releases [1]: https://img.shields.io/github/actions/workflow/status/kubenetworks/kubevpn/release.yml?logo=github

KubeVPN

中文 | English | Wiki

KubeVPN offers a Cloud-Native Dev Environment that seamlessly connects to your Kubernetes cluster network.

Gain access to the Kubernetes cluster network effortlessly using service names or Pod IP/Service IP. Facilitate the interception of inbound traffic from remote Kubernetes cluster services to your local PC through a service mesh and more.

For instance, you have the flexibility to run your Kubernetes pod within a local Docker container, ensuring an identical environment, volume, and network setup. With KubeVPN, empower yourself to develop applications entirely on your local PC!

Content

  1. QuickStart
  2. Functions
  3. Architecture
  4. Contributions

QuickStart

Install from script ( macOS / Linux)

bash
curl -fsSL https://kubevpn.dev/install.sh | sh

Install from brew (macOS / Linux)

bash
brew install kubevpn

Install from snap (Linux)

bash
sudo snap install kubevpn

Install from scoop (Windows)

bash
scoop bucket add extras
scoop install kubevpn

Install from krew (Windows / macOS / Linux)

bash
kubectl krew index add kubevpn https://github.com/kubenetworks/kubevpn.git
kubectl krew install kubevpn/kubevpn 
kubectl kubevpn 

Install from GitHub release (Windows / macOS / Linux)

https://github.com/kubenetworks/kubevpn/releases/latest

Install bookinfo as demo application

bash
kubectl apply -f https://raw.githubusercontent.com/kubenetworks/kubevpn/master/samples/bookinfo.yaml

For clean up after test

bash
kubectl delete -f https://raw.githubusercontent.com/kubenetworks/kubevpn/master/samples/bookinfo.yaml

Functions

Connect to k8s cluster network

use command kubevpn connect connect to k8s cluster network, prompt Password: need to input computer password. to enable root operation (create a tun device).

…

already connected to cluster network, use command kubevpn status to check status

bash
➜  ~ kubevpn status
CURRENT   CONNECTION ID   CLUSTER                 KUBECONFIG                      NAMESPACE   STATUS      NETIF
*         03dc50feb8c3    ccijorbccotmqodvr189g   /Users/naison/.kube/config      default     connected   utun4
➜  ~

use pod productpage-788df7ff7f-jpkcs IP 172.29.2.134

…

use ping to test connection, seems good

bash
➜  ~ ping 172.29.2.134
PING 172.29.2.134 (172.29.2.134): 56 data bytes
64 bytes from 172.29.2.134: icmp_seq=0 ttl=63 time=55.727 ms
64 bytes from 172.29.2.134: icmp_seq=1 ttl=63 time=56.270 ms
64 bytes from 172.29.2.134: icmp_seq=2 ttl=63 time=55.228 ms
64 bytes from 172.29.2.134: icmp_seq=3 ttl=63 time=54.293 ms
^C
--- 172.29.2.134 ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 54.293/55.380/56.270/0.728 ms

use service productpage IP 172.21.10.49

…

use command curl to test service connection

bash
➜  ~ curl 172.21.10.49:9080
<!DOCTYPE html>
<html>
  <head>
    <title>Simple Bookstore App</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

seems good too~

Domain resolve

support k8s dns name resolve.

a Pod/Service named productpage in the default namespace can successfully resolve by following name:

  • productpage
  • productpage.default
  • productpage.default.svc.cluster.local
bash
➜  ~ curl productpage.default.svc.cluster.local:9080
<!DOCTYPE html>
<html>
  <head>
    <title>Simple Bookstore App</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

Short domain resolve

To access the service in the cluster, service name or you can use the short domain name, such as productpage

bash
➜  ~ curl productpage:9080
<!DOCTYPE html>
<html>
  <head>
    <title>Simple Bookstore App</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
...

Disclaimer: This only works on the namespace where kubevpn-traffic-manager is deployed. Otherwise, use Domain resolve

Local outbound proxy for nested VPNs

If your operating system routes are controlled by another VPN client, route-based access may not work reliably even though kubevpn connect succeeds. In that case, use a local outbound proxy instead of depending on cluster CIDR routing.

Start a standalone local SOCKS5 proxy:

bash
➜  ~ kubevpn proxy-out --listen-socks 127.0.0.1:1080
Proxy hint: export ALL_PROXY=socks5h://127.0.0.1:1080
Proxy scope: TCP traffic only. Use socks5h if you want proxy-side cluster DNS resolution.

Then access cluster Services, Pod IPs, or Service ClusterIPs through the proxy:

bash
➜  ~ curl --proxy socks5h://127.0.0.1:1080 http://productpage.default.svc.cluster.local:9080
➜  ~ curl --proxy socks5h://127.0.0.1:1080 http://172.21.10.49:9080

Or start the managed SOCKS5 proxy as part of connect:

bash
➜  ~ kubevpn connect --socks
Started managed local SOCKS5 proxy for connection 03dc50feb8c3 on 127.0.0.1:1080
Proxy hint: export ALL_PROXY=socks5h://127.0.0.1:1080
Proxy scope: TCP traffic only. Use socks5h if you want proxy-side cluster DNS resolution.

Use kubevpn disconnect <connection-id> or kubevpn quit to stop the managed proxy. In this version, outbound proxy mode supports TCP traffic only.

Connect to multiple kubernetes cluster network

already connected cluster ccijorbccotmqodvr189g

bash
➜  ~ kubevpn status
CURRENT   CONNECTION ID   CLUSTER                 KUBECONFIG                      NAMESPACE   STATUS      NETIF
*         03dc50feb8c3    ccijorbccotmqodvr189g   /Users/naison/.kube/config      default     connected   utun4

then connect to another cluster ccidd77aam2dtnc3qnddg

bash
➜  ~ kubevpn connect -n default --kubeconfig ~/.kube/dev_config
Starting connect
Got network CIDR from cache
Use exist traffic manager
Forwarding port...
Connected tunnel
Adding route...
Configured DNS service
Now you can access resources in the kubernetes cluster !

use command kubevpn status to check connection status

bash
➜  ~ kubevpn status
CURRENT   CONNECTION ID   CLUSTER                 KUBECONFIG                      NAMESPACE   STATUS      NETIF
          03dc50feb8c3    ccijorbccotmqodvr189g   /Users/naison/.kube/config      default     connected   utun4
*         86bfdef0ed05    ccidd77aam2dtnc3qnddg   /Users/naison/.kube/dev_config  default     connected   utun5
➜  ~

Reverse proxy

use command kubevpn proxy to proxy all inbound traffic to local computer.

bash
➜  ~ kubevpn proxy deployment/productpage
Connected to cluster
Injecting inbound sidecar for deployment/productpage
Checking rollout status for deployment/productpage
Waiting for deployment "productpage" rollout to finish: 1 old replicas are pending termination...
Waiting for deployment "productpage" rollout to finish: 1 old replicas are pending termination...
Rollout successfully for deployment/productpage
Now you can access resources in the kubernetes cluster !
➜  ~

show status

bash
➜  ~ kubevpn status
CURRENT   CONNECTION ID   CLUSTER                 KUBECONFIG                   NAMESPACE   STATUS      NETIF
*         03dc50feb8c3    ccijorbccotmqodvr189g   /Users/naison/.kube/config   default     connected   utun4

          CONNECTION ID   NAMESPACE   NAME                           HEADERS   PORTS        CURRENT PC
          03dc50feb8c3    default     deployments.apps/productpage   *         9080->9080   true
➜  ~

For local testing, save the following code as hello.go

go
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	http.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
		_, _ = io.WriteString(writer, "Hello world!")
		fmt.Printf(">>Received request: %s %s from %s\n", request.Method, request.RequestURI, request.RemoteAddr)
	})
	_ = http.ListenAndServe(":9080", nil)
}

and compile it

go build hello.go

then run it

./hello &
bash
export selector=productpage
export pod=`kubectl get pods -l app=${selector} -n default -o jsonpath='{.items[0].metadata.name}'`
export pod_ip=`kubectl get pod $pod -n default -o jsonpath='{.status.podIP}'`
curl -v -H "foo: bar" http://$pod_ip:9080/health

response would like below

❯ curl -v -H "foo: bar" http://$pod_ip:9080/health
*   Trying 192.168.72.77:9080...
* Connected to 192.168.72.77 (192.168.72.77) port 9080 (#0)
> GET /health HTTP/1.1
> Host: 192.168.72.77:9080
> User-Agent: curl/7.87.0
> Accept: */*
> foo: bar
> 
>>Received request: GET /health from xxx.xxx.xxx.xxx:52974
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Date: Sat, 04 Nov 2023 10:19:50 GMT
< Content-Length: 12
< Content-Type: text/plain; charset=utf-8
< 
* Connection #0 to host 192.168.72.77 left intact
Hello world!

also you can access via service name

bash
➜  ~ curl productpage:9080
Hello world!%
➜  ~ curl productpage.default.svc.cluster.local:9080
Hello world!%

Reverse proxy with mesh

Support HTTP, GRPC and WebSocket etc. with specific header "foo: bar" will route to your local machine

bash
➜  ~ kubevpn proxy deployment/productpage --headers foo=bar
Connected to cluster
Injecting inbound sidecar for deployment/productpage
Checking rollout status for deployment/productpage
Waiting for deployment "productpage" rollout to finish: 1 old replicas are pending termination...
Waiting for deployment "productpage" rollout to finish: 1 old replicas are pending termination...
Rollout successfully for deployment/productpage
Now you can access resources in the kubernetes cluster !
➜  ~

show status

bash
➜  ~ kubevpn status
CURRENT   CONNECTION ID   CLUSTER                 KUBECONFIG                   NAMESPACE   STATUS      NETIF
*         03dc50feb8c3    ccijorbccotmqodvr189g   /Users/naison/.kube/config   default     connected   utun4

          CONNECTION ID   NAMESPACE   NAME                           HEADERS   PORTS        CURRENT PC
          03dc50feb8c3    default     deployments.apps/productpage   foo=bar   9080->9080   true
➜  ~

first access without header "foo: bar", it will access existing pod on kubernetes cluster.

bash
➜  ~ curl productpage:9080
<!DOCTYPE html>
<html>
  <head>
    <title>Simple Bookstore App</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name=

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Gocloud-nativecontrol-planedeveloper-toolsdevops

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
CategoryDevOps
PricingOpen source

> Related tools

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理