Kong / kong

🦍 The Cloud-Native API Gateway and AI Gateway.
https://konghq.com/install/#kong-community
Apache License 2.0
39k stars 4.78k forks source link

Improvement: add /readiness endpoint for Kubernetes hosting #1678

Closed JorritSalverda closed 3 years ago

JorritSalverda commented 8 years ago

Summary

To run Kong in Kubernetes a /readiness endpoint will tell Kubernetes whether a node is ready to receive traffic and make it part of a service by returning 200 OK. Failing to return 200 OK will - temporarily - remove the node from the service.

Combined with the /liveness endpoint - see https://github.com/Mashape/kong/issues/1677 - this makes running Kong in Kubernetes much more effective.

pamiel commented 7 years ago

+1 For sure would be very usefull for the integration of Kong into Kubernetes, for a production grade level.

erikgrinaker commented 7 years ago

@JorritSalverda Kong already comes with a kong health command to check its health, this can be used as a readiness/liveness probe:

        readinessProbe:
          exec:
            command:
            - kong
            - health
          initialDelaySeconds: 3
filotti commented 7 years ago

Kubernetes Ingress requires the readinessProbe to be an httpGet (without autentication), and I'm having a hard time finding an endpoint on the proxy port that returns http status 200 without calling another API...

filotti commented 7 years ago

I was able to solve my problem by adding a dummy API with a non-existent upstream uri and then using the request-termination plugin to always return status 200.

mvanholsteijn commented 6 years ago

I would like to have a proper HTTP health check for Kong too. In our situation, we have Kong fronted by an AWS ELB which executes HTTP requests for health checking.

As I have the global http-log plugin configured, @filotti's solution causes all the health checks (6 per minute per ELB instance per Kong instance to be logged.

the /liveness can be easily added to the kong NGiNX template.

the /readiness would ready to determine the health state of Kong.