我已经通过 microk8s 在 kubernetes 中部署了 angular 前端和 python 后端作为单独的 pod,它们正在运行。我在我的角度文件中将后端 url 指定为“ http://backend-service.default.svc.cluster.local:30007 ”,以便将前端与后端链接起来。但这会引发 ERR_NAME_NOT_RESOLVED。有人可以帮助我理解这个问题吗?
另外,我有一个配置文件,它在我的后端指定 ip 的端口和其他配置。在将 t 部署到 kubernetes 之前,我是否需要对该文件进行任何更改(数据库主机的值?、烧瓶主机?、端口?)?
下面显示的是我的角度和后端的部署和服务文件。
apiVersion: v1
kind: Service
metadata:
name: angular-service
spec:
type: NodePort
selector:
app: angular
ports:
- protocol: TCP
nodePort: 30042
targetPort: 4200
port: 4200
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: angular-deployment
labels:
name: angular
spec:
replicas: 1
selector:
matchLabels:
name: angular
template:
metadata:
labels:
name: angular
spec:
containers:
- name: angular
image: angular:local
ports:
- containerPort: 4200
apiVersion: v1
kind: Service
metadata:
name: backend-service
spec:
type:ClusterIP
selector:
name: backend
ports:
- protocol: TCP
targetPort: 7000
port: 7000
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend-deployment
labels:
name: backend
spec:
replicas: 1
selector:
matchLabels:
name: backend
template:
metadata:
labels:
name: backend
spec:
containers:
- name: backend
image: flask:local
ports:
- containerPort: 7000