bachr
bachr

Reputation: 6006

GKE set custom response code for ingress healthcheck

I'm trying to create a simple ingress for kibana with something like this

## kibana-ingress.yml ##
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: kibana-ingress
  namespace: monit
spec:
  rules:
    - host: 34.72.13.154
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: kibana-kibana
                port:
                  number: 5601

It seems that kibana has a health check at /app/kibana but when Auth is enabled this path will be redirected to 302 and thus causing the GKE ingress healthcheck to fail (as it expects a response code to be 200).

In the doc, I saw the mention of Expected Response so I tried the following backend config

## healthcheck-backendconfig.yml ##
apiVersion: cloud.google.com/v1
kind: BackendConfig
metadata:
  name: healthcheck-backendconfig
  namespace: monit
spec:
  logging:
    enable: true
    sampleRate: 0.1
  healthCheck:
    checkIntervalSec: 600
    timeoutSec: 40
    healthyThreshold: 1
    unhealthyThreshold: 3
    type: HTTP
    requestPath: /app/kibana
    port: 5601
    expectedResponse: 302

But this fails

Error from server (BadRequest): error when creating "healthcheck-backendconfig.yml": BackendConfig in version "v1" cannot be handled as a BackendConfig: strict decoding error: unknown field "spec.healthCheck.expectedResponse"

Is there a way to use a custom response code in this case? anything than 5xx should work here

Upvotes: 0

Views: 149

Answers (1)

The error message you are getting is due to the expectedResponse field not existing. You can read more about the available fields for a BackendConfig health check in the following docs.

GKE official documentation states you can't change the expected response from HTTP 200 (OK).

Upvotes: 0

Related Questions