从 Minikube 内部调用外部服务 [英] Calling an external service from within Minikube

查看:36
本文介绍了从 Minikube 内部调用外部服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 Minikube(安装在我的 Mac 上)中有一个服务 (/deployment/pod) 需要调用直接在我的 Mac 上运行的外部 http 服务(即 Minikube 外部).该外部服务的域名定义在我的 Mac/etc/hosts 文件中.然而,我在 Minikube 中的服务无法调用该外部服务.知道我需要在哪里配置吗?非常感谢.

解决方案

创建 Endpoints 将流量转发到您想要的外部 IP 地址(您的本地机器).您可以使用 Endpoints 直接连接,但根据 Goole Cloud 最佳实践 (

创建您的端点

kind:端点api版本:v1元数据:名称:本地IP子集:- 地址:- ip: 10.240.0.4 # 你想要的端点的 IP端口:- port: 27017 # 你要访问的端口

然后创建你Service

种类:服务api版本:v1元数据:名称:本地IP规格:类型:集群IP端口:- 端口:27017目标端口:27017

现在您可以使用 Service 名称调用外部 http 服务.在这种情况下,loal-ip 就像 minikube 的任何其他内部服务一样.

I have a service (/deployment/pod) running in my Minikube (installed on my Mac) that needs to call an external http service that runs directly on my Mac (i.e. outside Minikube). The domain name of that external service is defined into my Mac /etc/hosts file. Yet, my service within Minikube cannot call that external service. Any idea what I need to configure where? Many thanks. C

解决方案

Create Endpoints that will forward traffic to your desire external IP address (your local machine). You can directly connect using Endpoints but according to Goole 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.

这篇关于从 Minikube 内部调用外部服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆