Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
685 views
in Technique[技术] by (71.8m points)

kubernetes - Calling an external service from within 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

enter image description here

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...