Openvpn

在 k8s 容器中執行 OpenVPN

  • July 18, 2019

假設我有一個服務 IP 範圍為10.198.240.0/20的 k8s 集群。

現在我希望這個 IP 範圍可以從另一個集群或數據中心訪問。

在 kubernetes POD 中執行 OpenVPN 以便可以通過 VPN 訪問此 IP 範圍是否可行?

有同樣的問題並提出了這個解決方案

試試看,讓我知道它是否適合你。

指示:

docker run --user=$(id -u) -e OVPN_SERVER_URL=tcp://vpn.my.fqdn:1194 \
-v $PWD:/etc/openvpn:z -ti ptlange/openvpn ovpn_initpki
docker run --user=$(id -u) -e EASYRSA_CRL_DAYS=180 \
-v $PWD:/etc/openvpn:z -ti ptlange/openvpn easyrsa gen-crl

獲取服務ID

$ ./kube/deploy.sh
Usage: ./kube/deploy.sh <namespace> <OpenVPN URL> <service cidr> <pod cidr>

$ ./kube/deploy.sh default tcp://vpn.my.fqdn:1194 10.3.0.0/24 10.2.0.0/16
secret "openvpn-pki" created
configmap "openvpn-settings" created
configmap "openvpn-ccd" created
deployment "openvpn" created
You have exposed your service on an external port on all nodes in your
cluster.  If you want to expose this service to the external internet, you may
need to set up firewall rules for the service port(s) (tcp:30xxx) to serve traffic.

See http://releases.k8s.io/release-1.3/docs/user-guide/services-firewalls.md for
more details. service "openvpn-ingress" created

引用自:https://serverfault.com/questions/768941