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

Kubernetes nginx ingress controller throws error when trying to obtain endpoints for service

我正在尝试在 Google 云平台上的 Kubernetes 上设置微服务。我创建了 deploymentclusterIpingress 配置文件。

首先在创建集群后,我运行这个命令来安装nginx ingress。

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

我用helm v3.

然后我应用部署和 clusterIp 配置。

部署和 clusterIp 配置:

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

我从 Google 带有入口控制器的云平台日志中得到这个错误:

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