Ingress-Nginx-Controller未能找到部署在Google Cloud Platform上的第二项服务

问题描述 投票:0回答:1

我在GCP上部署了以下2种服务(使用Java内置):

部署和公开服务的Yaml 1:

kind: Service
apiVersion: v1
metadata:
  name: mply6
spec:
  selector: 
      app: mply6
  ports:
     - protocol: "TCP"
       port:  80
       targetPort:  8080
  type: LoadBalancer
  loadBalancerIP: "35.223.241.9"

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mply6
spec:
  replicas: 1
  selector: 
    matchLabels:
      app: mply6
  template:
    metadata:
      labels:
        app: mply6
    spec:
      containers:
      - name: mply6
        image: gcr.io/mply6-271000/mply6:latest
        ports:
        - containerPort: 8080

用于部署和公开服务的Yaml 2:

kind: Service
apiVersion: v1
metadata:
  name: gami6
spec:
  selector: 
      app: gmai6
  ports:
     - protocol: "TCP"
       port:  81
       targetPort:  8081
  type: LoadBalancer
  loadBalancerIP: "35.223.241.9"

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: gami6
spec:
  replicas: 1
  selector: 
    matchLabels:
      app: gami6
  template:
    metadata:
      labels:
        app: gami6
    spec:
      containers:
      - name: gami6
        image: gcr.io/mply6-271000/gami6:latest
        ports:
        - containerPort: 8081

而且,用于创建Ingress资源的Yaml:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: basic-ingress
  annotations:
    kubernetes.io/ingress.global-static-ip-name: "35.223.241.9"
spec:
  rules:
  - http:
      paths:
      - path: /path1
        backend:
          serviceName: mply6
          servicePort: 80
      - path: /path2
        backend:
          serviceName: gami6
          servicePort: 81

此外,'kubectl的结果描述了入口基本入口':

Name:             basic-ingress
Namespace:        default
Address:          35.244.199.199
Default backend:  default-http-backend:80 (10.60.1.4:8080)
Rules:
  Host  Path  Backends
  ----  ----  --------
  *
        /multiplications/random   mply6:80 (10.60.0.32:8080)
        /results                  mply6:80 (10.60.0.32:8080)
        /leaders                  gami6:81 (10.60.0.32:8081)
        /stats                    gami6:81 (10.60.0.32:8081)
Annotations:
  kubernetes.io/ingress.global-static-ip-name:  35.223.241.9
Events:
  Type     Reason     Age                   From                      Message
  ----     ------     ----                  ----                      -------
  Normal   CREATE     35m                   nginx-ingress-controller  Ingress default/basic-ingress
  Warning  Translate  21m                   loadbalancer-controller   error while evaluating the ingress spec: could not find service "default/gami6"; could not find service"
default/gami6"
  Warning  Translate  6m17s (x34 over 77m)  loadbalancer-controller   error while evaluating the ingress spec: could not find port "8081" in service "default/gami6"; could no
t find port "8081" in service "default/gami6"
  Normal   CREATE     44s (x1153 over 22h)  loadbalancer-controller   ip: 35.244.199.199
  Normal   UPDATE     7s (x13 over 35m)     nginx-ingress-controller  Ingress default/basic-ingress

基本上,我期望当我给URL'http://example.com/path2'时,Ingress-Nginx-Controller会找到第二个服务'gami6',但是为什么出现上述错误消息:找不到服务“ default / gami6 “? (在没有问题的情况下可以找到http://example.com/path1

service google-cloud-platform nginx-ingress
1个回答
0
投票

我无法在上面的部署中添加任何备注。但是,此部署与http-balancer documentation

非常相似

我尝试了文档中提到的部署,并且能够实现您想要做的事情。使负载均衡器根据路径路由请求。

© www.soinside.com 2019 - 2024. All rights reserved.