Kubernetes nginx 入口控制器在尝试获取服务的端点时抛出错误



我正在尝试在Google Cloud Platform上的Kubernetes上设置微服务。我创建了一个deploymentclusterIpingress配置文件。

首先在创建集群后,我运行此命令来安装nginx入口。

helm install my-nginx stable/nginx-ingress --set rbac.create=true

我使用helm v3.

然后,我应用部署和群集 IP 配置。

部署和集群 IP 配置:

apiVersion: apps/v1
kind: Deployment
metadata:
name: app-production-deployment
spec:
replicas: 2
selector:
matchLabels:
component: app-production
template:
metadata:
labels:
component: app-production
spec:
containers:
- name: app-production
image: eu.gcr.io/my-project/app:1.0
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: app-production-cluser-ip-service
spec:
type: ClusterIP
selector:
component: app-production
ports:
- port: 80
targetPort: 80
protocol: TCP

我的入口配置是:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-service
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: app.example.com
http:
paths:
- path: /
backend:
serviceName: app-production-cluster-ip-service
servicePort: 80

我从入口控制器中的谷歌云平台日志中收到此错误:

Error obtaining Endpoints for Service "default/app-production-cluster-ip-service": no object matching key "default/app-production-cluster-ip-service" in local store

但是当我执行kubectl get endpoints命令时,输出是这样的:

NAME                                          ENDPOINTS                     AGE
app-production-cluser-ip-service              10.60.0.12:80,10.60.1.13:80   17m

我真的不确定我做错了什么。

入口中提到的服务名称不匹配。请重新创建服务并检查

apiVersion: v1
kind: Service
metadata:
name: app-production-cluster-ip-service
spec:
type: ClusterIP
selector:
component: app-production
ports:
- port: 80
targetPort: 80
protocol: TCP

最新更新