如何通过ssh隧道使用kubectl通过我的kubernetes API访问我的内部ELB?

问题描述 投票:3回答:1

我想使用完全使用私有拓扑的KOPS创建kubernetes集群(所有主节点/工作节点都在私有子网上,API ELB在内部)。

创建集群后 - 如何配置kubectl以通过我的堡垒服务器使用ssh隧道?

kubernetes kubectl ssh-tunnel kops
1个回答
1
投票

您可以通过SSH使用VPN,这对您的kubectl是透明的,示例工具:使用SSH和iptables创建VPN隧道的https://github.com/sshuttle/sshuttle

要求是在堡垒主机上至少有python 2.3。


1
投票

我发现了一种让kubectl通过SSH隧道的方法,它并不理想,但在我找到更好的东西之前,我现在发布了它。

首先创建隧道:

ssh -f [email protected] -L 6443:localhost:6443 -N

然后复制本地计算机上的~/.kube/config文件并更改群集server以指向127.0.0.1而不是服务器URL或IP地址。

由于证书是为创建主节点的服务器制作的,因此会出现以下错误:

Unable to connect to the server: x509: certificate is valid for 10.96.0.1, 10.0.0.1, not 127.0.0.1

你必须通过--insecure-skip-tls-verify=true标志:

kubectl --insecure-skip-tls-verify=true version
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.3", GitCommit:"5e53fd6bc17c0dec8434817e69b04a25d8ae0ff0", GitTreeState:"clean", BuildDate:"2019-06-06T01:44:30Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.1", GitCommit:"4485c6f18cee9a5d3c3b4e523bd27972b1b53892", GitTreeState:"clean", BuildDate:"2019-07-18T09:09:21Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}

我希望这有帮助,我希望找到一个更好的方法来避免这个--insecure-skip-tls-verify=true标志。

© www.soinside.com 2019 - 2024. All rights reserved.