【发布时间】:2019-04-12 22:09:16
【问题描述】:
我在 minikube 中有一个 python 应用和 vue-js 应用。我试图通过在 URL 中提及“python-app-service”来向 python 应用程序服务发帖,但是 vue js 仍然将其应用为文字“python-app-service”而不是 IP 地址。
假设这是我的部署,称为python-server:
spec:
containers:
- image: python-server:latest
imagePullPolicy: IfNotPresent
name: python-servier
ports:
- containerPort: 8001
name: python-server
我的服务叫python-server-service
spec:
ports:
- port: 8001
targetPort: 8001
另一方面,我为 vue js 提供了类似的 deploymet 和服务。
现在我想在 vue js 中向python-server 发送 axios 发布请求:
axios.post('python-server-service'+'/api/new/post',
this.name, // the data to post
{ headers: {
'Content-type': 'application/x-www-form-urlencoded',
}
}).then(response => ....);
而不是这个:
axios.post('http://127.0.0.1:3030/api/new/post',
this.name, // the data to post
{ headers: {
'Content-type': 'application/x-www-form-urlencoded',
}
}).then(response => ....);
但不幸的是,vueJS 不会解析我的python-server-service 并将其作为文字字符串“python-server-service”。
如何在 minikube 中运行的 vuejs 中获取 python-app-service IP 地址?
谢谢。
【问题讨论】:
标签: python vue.js kubernetes minikube