我正在使用VPN连接从我的笔记本电脑上访问企业资源,但我无法从Minikube创建的虚拟机访问这些资源。然而,我无法从Minikube创建的虚拟机访问这些资源。
我希望能够做到以下几点 这个 但外部资源的地址从集群中无法到达。
有什么办法可以让我用Minikube做到这一点?
你需要确保你已经正确定义了 endpoints
和 services
. 这样Kubernetes会将pod内部的请求重定向到所需的外部IP。这在 本回答 我把它作为一个社区维基贴在这里。
创建
Endpoints
将流量转发到你想要的外部IP地址(你的本地机器)。您可以直接使用Endpoints
但据Google Cloud best practice
(文档)是通过一个Service
创建您的
Endpoints
kind: Endpoints apiVersion: v1 metadata: name: local-ip subsets: - addresses: - ip: 10.240.0.4 # IP of your desire end point ports: - port: 27017 # Port that you want to access Then create you `Service` kind: Service apiVersion: v1 metadata: name: local-ip Spec: type: ClusterIP ports: - port: 27017 targetPort: 27017
现在你可以使用
Service
名。在这种情况下loal-ip
如同其他的内部服务minikube
.
请告诉我是否有帮助。
实际上,我可以通过以下方式从虚拟机访问公司网络。下载最新版本的virtualbox 并以此作为 --vm-driver
的minikube,同时连接到我的笔记本电脑上的VPN。(之前用的是hyperkit)
minikube start --vm-driver=virtualbox