diff --git a/etc/init_kong.sh b/etc/init_kong.sh index bac2b82..cae4e3b 100755 --- a/etc/init_kong.sh +++ b/etc/init_kong.sh @@ -378,6 +378,23 @@ _format_version: "3.0" _transform: true services: + # Dedicated health endpoint for the GCE LB BackendConfig. request-termination + # returns 200 synchronously with no upstream call, so the probe passes as long + # as the Kong proxy itself is running. GCE rejects \`type: TCP\` in BackendConfig + # (only HTTP/HTTPS/HTTP2 accepted), so we use this route for HTTP liveness. + - name: healthz + url: http://127.0.0.1:${KONG_PROXY_PORT}/ + routes: + - name: healthz + paths: + - /healthz + strip_path: true + plugins: + - name: request-termination + config: + status_code: 200 + message: ok + - name: prole-service url: ${PROLE_SERVICE_UPSTREAM_URL} routes: @@ -608,9 +625,13 @@ EOF # BackendConfig: GCE default healthCheck is HTTP GET / on the backend port # and Kong returns 404 on an unrouted path, so the backend never goes - # HEALTHY. A TCP healthCheck on the proxy port is sufficient for our case - # (backend is alive as long as Kong is accepting connections). Service is - # annotated below with cloud.google.com/backend-config so GCE picks this up. + # HEALTHY. We wanted TCP (Kong is alive as long as it accepts connections), + # but GCE's BackendConfig CRD rejects `type: TCP` with + # `Protocol "TCP" is not valid, must be one of [HTTP,HTTPS,HTTP2]` + # so we fall back to HTTP against the `/healthz` route we add to the + # knoe-svc-kong declarative config above (request-termination plugin + # returns 200 synchronously, no upstream dependency -- equivalent liveness + # semantics to a TCP check but over a protocol GCE accepts). echo "Reconciling BackendConfig (${SVC_KNOE_BACKEND_CONFIG_NAME}) for ${KONG_NAME} in ns=${NAMESPACE} ..." kubectl apply -f - <