我有一项服务 (/deployment/pod) 在我的 Minikube(安装在我的 Mac 上)中运行,需要调用直接在我的 Mac 上(即在 Minikube 外部)运行的外部 http 服务。该外部服务的域名定义在我的 Mac/etc/hosts 文件中。然而,我在 Minikube 中的服务无法调用该外部服务。知道我需要在哪里配置什么吗?非常感谢。 C
最佳答案
创建 Endpoints
将流量转发到您想要的外部 IP 地址(您的本地计算机)。您可以使用 Endpoints
直接连接,但根据 Goole Cloud 最佳实践
( doc ) 是通过 Service
创建您的端点
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
然后创建你的Service
kind: Service
apiVersion: v1
metadata:
name: local-ip
spec:
type: ClusterIP
ports:
- port: 27017
targetPort: 27017
现在您可以使用Service
名称调用外部http 服务。在这种情况下,local-ip
就像 minikube
的任何其他内部服务一样。
关于kubernetes - 从 Minikube 内部调用外部服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54464722/