From 19e0db544c030edf1f7f685e46229381b5fee66f Mon Sep 17 00:00:00 2001 From: Isman Firmansyah Date: Fri, 4 Aug 2023 12:58:57 +0700 Subject: [PATCH] feat(docker-jans-link): add healthcheck support (#5777) --- charts/janssen/charts/link/README.md | 6 +++--- charts/janssen/charts/link/values.yaml | 18 ++++++++++-------- docker-jans-link/Dockerfile | 4 ++-- docker-jans-link/scripts/healthcheck.py | 20 ++++++++++++++++++++ 4 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 docker-jans-link/scripts/healthcheck.py diff --git a/charts/janssen/charts/link/README.md b/charts/janssen/charts/link/README.md index ba9f9de0d12..77ff0cb639f 100644 --- a/charts/janssen/charts/link/README.md +++ b/charts/janssen/charts/link/README.md @@ -39,11 +39,11 @@ Kubernetes: `>=v1.21.0-0` | image.repository | string | `"ghcr.io/janssenproject/jans/link"` | Image to use for deploying. | | image.tag | string | `"1.0.17_dev"` | Image tag to use for deploying. | | lifecycle | object | `{}` | | -| livenessProbe | object | `{"httpGet":{"path":"/jans-link/api/v1/health/live","port":9091},"initialDelaySeconds":30,"periodSeconds":30,"timeoutSeconds":5}` | Configure the liveness healthcheck for the auth server if needed. | -| livenessProbe.httpGet | object | `{"path":"/jans-link/api/v1/health/live","port":9091}` | Executes the python3 healthcheck. | +| livenessProbe | object | `{"exec":{"command":["python3","/app/scripts/healthcheck.py"]},"initialDelaySeconds":30,"periodSeconds":30,"timeoutSeconds":5}` | Configure the liveness healthcheck for the link if needed. | +| livenessProbe.exec | object | `{"command":["python3","/app/scripts/healthcheck.py"]}` | Executes the python3 healthcheck. | | nameOverride | string | `""` | | | nodeSelector | object | `{}` | | -| readinessProbe | object | `{"httpGet":{"path":"/jans-link/api/v1/health/ready","port":9091},"initialDelaySeconds":25,"periodSeconds":25,"timeoutSeconds":5}` | Configure the readiness healthcheck for the auth server if needed. | +| readinessProbe | object | `{"exec":{"command":["python3","/app/scripts/healthcheck.py"]},"initialDelaySeconds":25,"periodSeconds":25,"timeoutSeconds":5}` | Configure the readiness healthcheck for the link if needed. | | replicas | int | `1` | Service replica number. | | resources | object | `{"limits":{"cpu":"500m","memory":"1000Mi"},"requests":{"cpu":"500m","memory":"1000Mi"}}` | Resource specs. | | resources.limits.cpu | string | `"500m"` | CPU limit. | diff --git a/charts/janssen/charts/link/values.yaml b/charts/janssen/charts/link/values.yaml index 3b6127025e2..220d86e46cd 100644 --- a/charts/janssen/charts/link/values.yaml +++ b/charts/janssen/charts/link/values.yaml @@ -57,20 +57,22 @@ service: sessionAffinityConfig: clientIP: timeoutSeconds: 10800 -# -- Configure the liveness healthcheck for the auth server if needed. +# -- Configure the liveness healthcheck for the link if needed. livenessProbe: # -- Executes the python3 healthcheck. - httpGet: - path: /jans-link/api/v1/health/live - port: 9091 + exec: + command: + - python3 + - /app/scripts/healthcheck.py initialDelaySeconds: 30 periodSeconds: 30 timeoutSeconds: 5 -# -- Configure the readiness healthcheck for the auth server if needed. +# -- Configure the readiness healthcheck for the link if needed. readinessProbe: - httpGet: - path: /jans-link/api/v1/health/ready - port: 9091 + exec: + command: + - python3 + - /app/scripts/healthcheck.py initialDelaySeconds: 25 periodSeconds: 25 timeoutSeconds: 5 diff --git a/docker-jans-link/Dockerfile b/docker-jans-link/Dockerfile index e457f8e3985..42d84d74b09 100644 --- a/docker-jans-link/Dockerfile +++ b/docker-jans-link/Dockerfile @@ -46,8 +46,8 @@ RUN wget -q https://maven.jans.io/maven/io/jans/jython-installer/${JYTHON_VERSIO # ==== ENV CN_VERSION=1.0.17-SNAPSHOT -ENV CN_BUILD_DATE='2023-07-13' -ENV CN_SOURCE_URL=https://jenkins.jans.io/maven/io/jans/jans-link/${CN_VERSION}/jans-link-${CN_VERSION}.war +ENV CN_BUILD_DATE='2023-08-03 16:58' +ENV CN_SOURCE_URL=https://jenkins.jans.io/maven/io/jans/jans-link-server/${CN_VERSION}/jans-link-server-${CN_VERSION}.war RUN mkdir -p ${JETTY_BASE}/jans-link/webapps \ && wget -q ${CN_SOURCE_URL} -O /tmp/jans-link.war \ diff --git a/docker-jans-link/scripts/healthcheck.py b/docker-jans-link/scripts/healthcheck.py new file mode 100644 index 00000000000..ffc0ed06dd7 --- /dev/null +++ b/docker-jans-link/scripts/healthcheck.py @@ -0,0 +1,20 @@ +import sys + +import requests + + +def main(): + req = requests.get("http://0.0.0.0:9091/jans-link/sys/health-check") + if not req.ok: + sys.exit(1) + + data = req.json() + if data["status"] == "running" and data["db_status"] == "online": + sys.exit(0) + + # any other value will be considered as unhealthy + sys.exit(1) + + +if __name__ == "__main__": + main()