Google Cloud Platform (GCP) Ingress unhealthy backend

5/17/2019

I have the following deployment running in Google Cloud Platform (GCP):

    kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  name: mybackend
  labels:
    app: backendweb
spec:
  replicas: 1
  selector:
    matchLabels:
      app: backendweb
      tier: web
  template:
    metadata:
      labels:
        app: backendweb
        tier: web
    spec:
      containers:
        - name: mybackend
          image: eu.gcr.io/teststuff/backend:latest
          ports:
            - containerPort: 8081

This uses the following service:

apiVersion: v1
kind: Service
metadata:
  name: mybackend
  labels:
    app: backendweb
spec:
  type: NodePort
  selector:
    app: backendweb
    tier: web
  ports:
    - port: 8081
      targetPort: 8081

Which uses this ingress:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress
  annotations:
    kubernetes.io/ingress.global-static-ip-name: backend-ip
  labels:
    app: backendweb
spec:
  backend:
    serviceName: mybackend
    servicePort: 8081

When I spin all this up in Google Cloud Platform however, I get the following error message on my ingress:

All backend services are in UNHEALTHY state

I've looked through my pod logs with no indication about the problem. Grateful for any advice!

-- Nespony
google-cloud-platform
kubernetes

1 Answer

5/18/2019

Most likely this problem is caused by not returning 200 on route '/' for your pod. Please check your pod configurations. If you don't want to return 200 at route '/', you could add a readiness rule for health check like this:

readinessProbe:
    httpGet:
        path: /healthz
        port: 80
    initialDelaySeconds: 5
    periodSeconds: 5
-- Fei
Source: StackOverflow