0
votes

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
I just had the same problem like two days, at the end it was because my app was redirecting "/" path to path "/b", and for cheking health you must not redirect in "/", you app must return 200John Balvin Arias
I have tested this service container locally and it's working right.Abdul Rehman
this is likely not a firewall rule issue, can you curl the exposed service though the nodeport to see if you get a 200 response? curl [node_IP]:30002Patrick W
Hi @PatrickW, thanks for hitting up here, do both services need to return 200 at / or first service only need?Abdul Rehman
each service will act as a separate backend, so each one is probed separately and needs to return 200Patrick W

1 Answers

1
votes

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'.