从 Minikube 访问公司资源
Access corporate resources from Minikube
我正在使用 VPN 连接从我的笔记本电脑访问公司资源。但是,我无法从 Minikube 创建的 VM 访问这些资源。
我希望能够完全做到this,但是集群无法访问外部资源的地址。
知道如何使用 Minikube 做到这一点吗?
您需要确保您已正确定义 endpoints
和 services
。这样 Kubernetes 会将请求从 pod 内部重定向到所需的外部 IP。它在 this answer 中有详细描述,我将其作为社区 Wiki 发布在这里:
Create Endpoints
that will forward traffic to your desire external
IP address (your local machine). You can directly connect using
Endpoints
but according to Google Cloud best practice
(doc) is
to access it through a Service
Create your 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
Now you can call external http service using the Service
name. In
this case loal-ip
like any other internal service of minikube
.
如果有帮助,请告诉我。
我实际上能够通过 downloading the latest version of virtualbox 从 VM 访问公司网络,并在连接到笔记本电脑上的 VPN 时将其用作 minikube 的 --vm-driver
。 (之前用过hyperkit)
minikube start --vm-driver=virtualbox
我正在使用 VPN 连接从我的笔记本电脑访问公司资源。但是,我无法从 Minikube 创建的 VM 访问这些资源。
我希望能够完全做到this,但是集群无法访问外部资源的地址。
知道如何使用 Minikube 做到这一点吗?
您需要确保您已正确定义 endpoints
和 services
。这样 Kubernetes 会将请求从 pod 内部重定向到所需的外部 IP。它在 this answer 中有详细描述,我将其作为社区 Wiki 发布在这里:
Create
Endpoints
that will forward traffic to your desire external IP address (your local machine). You can directly connect usingEndpoints
but according toGoogle Cloud best practice
(doc) is to access it through aService
Create your
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
Now you can call external http service using the
Service
name. In this caseloal-ip
like any other internal service ofminikube
.
如果有帮助,请告诉我。
我实际上能够通过 downloading the latest version of virtualbox 从 VM 访问公司网络,并在连接到笔记本电脑上的 VPN 时将其用作 minikube 的 --vm-driver
。 (之前用过hyperkit)
minikube start --vm-driver=virtualbox