Google Kubernetes Engine Ingress UNHEALTHY backend

2019-06-11 16:55发布

Kind Note: I have googled a lot and take a look too many questions related to this issue at StackOverflow also but couldn't solve my issue, that's why don't mark this as duplicate, please!

I'm trying to deploy 2 services (One is Python flask and other is NodeJS) on Google Kubernetes Engine. I have created two Kubernetes-deployments one for each service and two Kubernetes-services one for each service of type NodePort. Then, I have created an Ingress and mentioned my endpoints but Ingress says that One backend service is UNHEALTHY.

Here are my Deployments YAML definitions:

# Pyservice deployment
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: pyservice
  labels:
    app: pyservice
  namespace: default
spec:
  selector:
    matchLabels:
        app: pyservice
  template:
    metadata:
      labels:
        app: pyservice
    spec:
      containers:
      - name: pyservice
        image: docker.io/arycloud/docker_web_app:pyservice
        ports:
        - containerPort: 5000
      imagePullSecrets:
         - name: docksecret

# # Nodeservice deployment
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nodeservice
  labels:
    app: nodeservice
  namespace: default
spec:
  selector:
    matchLabels:
        app: nodeservice
  template:
    metadata:
      labels:
        app: nodeservice
        tier: web
    spec:
      containers:
      - name: nodeservice
        image: docker.io/arycloud/docker_web_app:nodeservice
        ports:
        - containerPort: 8080
      imagePullSecrets:
         - name: docksecret

And, here are my services and Ingress YAML definitions:

# pyservcie service
kind: Service
apiVersion: v1
metadata:
  name: pyservice
spec:
  type: NodePort
  selector:
    app: pyservice
  ports:
  - protocol: TCP
    port: 5000
    nodePort: 30001
---

# nodeservcie service
kind: Service
apiVersion: v1
metadata:
  name: nodeservcie
spec:
  type: NodePort
  selector:
    app: nodeservcie
  ports:
  - protocol: TCP
    port: 8080
    nodePort: 30002
---

# Ingress

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: my-ingress
  namespace: default
  annotations:
    kubernetes.io/ingress.class: "gce"
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - http:
      paths:
      - path: /
        backend:
          serviceName: pyservice
          servicePort: 5000
      - path: /*
        backend:
          serviceName: pyservice
          servicePort: 5000
      - path: /node/svc/
        backend:
          serviceName: nodeservcie
          servicePort: 8080

The pyservice is working fine but the nodeservice shows as UNHEALTHY backend. Here's a screenshot: enter image description here

Even I have edited the Firewall Rules for all gke-.... and allow all ports just for getting out from this issue, but it still showing the UNHEALTHY status for nodeservice.

What's wrong here?

Thanks in advance!

1条回答
\"骚年 ilove
2楼-- · 2019-06-11 17:29

Why are you using a GCE ingress class and then specifying a nginx rewrite annotation? In case you haven't realised, the annotation won't do anything to the GCE ingress.

You have also got 'nodeservcie' as your selector instead of 'nodeservice'.

查看更多
登录 后发表回答