gpt4 book ai didi

angular - Kubernetes:ERR_NAME_NOT_RESOLVED

转载 作者:行者123 更新时间:2023-12-02 11:30:50 25 4
gpt4 key购买 nike

我已经在 GKE 中部署了一个 mongo db、Spring Boot BE、Angular 应用程序。我的 FE 服务是一个负载均衡器,它需要与我的 BE 连接才能获取数据,但我的浏览器出现控制台错误:获取 http://contactbe.default.svc.cluster.local/contacts net::ERR_NAME_NOT_RESOLVED .我的 FE 需要使用/contacts 端点来获取数据。我在我的 Angular 应用程序中使用来自我的 BE 服务 (contactbe.default.svc.cluster.local) 的 DNS。这是我用来创建部署的 yml 文件:

apiVersion: v1
kind: Service
metadata:
name: mongo
labels:
run: mongo
spec:
type: NodePort
ports:
- port: 27017
targetPort: 27017
protocol: TCP
selector:
run: mongo
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: mongo
spec:
template:
metadata:
labels:
run: mongo
spec:
containers:
- name: mongo
image: mongo
ports:
- containerPort: 27017
---
apiVersion: v1
kind: Service
metadata:
name: contactbe
labels:
app: contactbe
spec:
type: NodePort
ports:
- port: 8181
targetPort: 8181
protocol: TCP
selector:
app: contactbe
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: contactbe
spec:
template:
metadata:
labels:
app: contactbe
spec:
containers:
- name: contactbe
image: glgelopfalcon/k8s_contactbe:latest
ports:
- containerPort: 8181
---
apiVersion: apps/v1beta1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
name: angular-deployment
spec:
selector:
matchLabels:
app: angular
replicas: 2 # tells deployment to run 2 pods matching the template
template:
metadata:
labels:
app: angular
spec:
containers:
- name: angular
image: glgelopfalcon/my-angular-app:latest
ports:
- containerPort: 80
---
# https://kubernetes.io/docs/concepts/services-networking/service/#defining-a-service
kind: Service
apiVersion: v1
metadata:
name: angular-service
spec:
selector:
app: angular
ports:
- port: 80
targetPort: 80
protocol: TCP
type: LoadBalancer

我用谷歌搜索了很多,但我仍然没有找到如何解决这个问题。如果有人可以伸出援手,我将不胜感激。

Console error

最佳答案

检查您的负载均衡器是否已打开端口 27017 作为您向端口 27017 的发送请求

否则您可以将服务节点端口更改为 80,目标端口将相同

关于angular - Kubernetes:ERR_NAME_NOT_RESOLVED,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54858192/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com