首页 文章

GKE Ingress - 简单的nginx示例但是收到错误“找不到后端的nodeport”

提问于
浏览
1

我正在尝试在GKE上创建一个简单的nginx服务,但我遇到了奇怪的问题 .

Nginx在Pod内的端口80上运行 . 该服务可在端口8080上访问 . (这样,我可以在pod中执行 curl myservice:8080 并查看nginx主屏幕)

但是当我尝试使用入口公开访问它时,我遇到了麻烦 . 这是我的部署,服务和入口文件 .

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80


kind: Service
apiVersion: v1
metadata:
  name: my-service
spec:
  selector:
    app: nginx
  ports:
  - protocol: TCP
    port: 8080
    nodePort: 32111
    targetPort: 80
  type: NodePort


apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: test-ingress
spec:
  rules:
  - http:
      paths:
      # The * is needed so that all traffic gets redirected to nginx
      - path: /*
        backend:
          serviceName: my-service
          servicePort: 80

过了一会儿,这就是我的入口状态:

$ k describe ingress test-ingress
Name:             test-ingress
Namespace:        default
Address:          35.186.255.184
Default backend:  default-http-backend:80 (10.44.1.3:8080)
Rules:
  Host  Path  Backends
  ----  ----  --------
  *
        /*   my-service:32111 (<none>)
Annotations:
  backends:         {"k8s-be-30030--ecc76c47732c7f90":"HEALTHY"}
  forwarding-rule:  k8s-fw-default-test-ingress--ecc76c47732c7f90
  target-proxy:     k8s-tp-default-test-ingress--ecc76c47732c7f90
  url-map:          k8s-um-default-test-ingress--ecc76c47732c7f90
Events:
  Type     Reason   Age               From                     Message
  ----     ------   ----              ----                     -------
  Normal   ADD      18m               loadbalancer-controller  default/test-ingress
  Normal   CREATE   17m               loadbalancer-controller  ip: 35.186.255.184
  Warning  Service  1m (x5 over 17m)  loadbalancer-controller  Could not find nodeport for backend {ServiceName:my-service ServicePort:{Type:0 IntVal:32111 StrVal:}}: could not find matching nodeport from service
  Normal   Service  1m (x5 over 17m)  loadbalancer-controller  no user specified default backend, using system default

我不知道它找不到nodeport - 该服务已经定义了nodePort,它也是NodePort类型 . 转到 default backend - 404 中的实际IP结果 .

有什么想法吗?

1 回答

  • 0

    配置缺少运行状况检查 endpoints ,以便GKE负载均衡器知道后端是否正常 . nginxcontainers 部分还应指定:

    livenessProbe:
       httpGet:
         path: /
         port: 80
    

    端口80上的 GET / 是默认配置,可以更改 .

相关问题