NOTE: In general case, you should not setup the VPN server on the kubernetes. If you need the VPN services, you should create an independent instance of it or use cloud platform’s VPN service. Otherwise, you may have some security risk.
Steps
-
Create
vpn.yaml
and replacevpn_ipsec_psk
,vpn_user
andvpn_password
by your secretapiVersion: apps/v1beta2 kind: StatefulSet metadata: name: vpn spec: selector: matchLabels: app: vpn serviceName: vpn replicas: 1 template: metadata: labels: app: vpn spec: containers: - name: vpn image: hwdsl2/ipsec-vpn-server imagePullPolicy: Always securityContext: privileged: true ports: - containerPort: 500 hostPort: 500 name: vpn-isakmp protocol: UDP - containerPort: 4500 hostPort: 4500 name: vpn-ike protocol: UDP env: - name: "VPN_IPSEC_PSK" value: "vpn_ipsec_psk" - name: "VPN_USER" value: "vpn_user" - name: "VPN_PASSWORD" value: "vpn_password"
-
Deploy to your cluster
kubectl apply -f vpn.yaml
-
Check your public IP of VPN server
kubectl logs vpn-0
And your will see below information
-
Open your VPN client and connect to VPN to check it