【发布时间】:2017-11-20 12:00:49
【问题描述】:
我有一个使用 Vuejs 编写的前端单页应用程序,我使用 axios 调用后端 API。我正在尝试使用 kubernetes 来运行服务:
我的部署和服务 yml 文件:
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: testapi
spec:
replicas: 1
template:
metadata:
labels:
app: testapi
spec:
containers:
- name: testapi
image: testregistry.azurecr.io/testapi:latest
ports:
- containerPort: 3001
---
apiVersion: v1
kind: Service
metadata:
name: testapi
spec:
type: LoadBalancer
ports:
- port: 3001
selector:
app: testapi
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: testportal
spec:
replicas: 1
template:
metadata:
labels:
app: testportal
spec:
containers:
- name: testportal
image: testregistry.azurecr.io/testportal
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: testportal
spec:
type: LoadBalancer
ports:
- port: 8080
selector:
app: testportal
前端在客户端浏览器上运行。我的 axios url 连接到http://testapi:3001,这显然不起作用。知道如何将其连接到支持的 API 吗?
【问题讨论】:
标签: docker kubernetes