From a1c7bfd14f05a4a91c9bf813a59a6ae1f45f5108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maro=C5=A1=20Roman?= <60748071+maroroman@users.noreply.github.com> Date: Mon, 11 Jul 2022 20:53:26 +0200 Subject: [PATCH] Jupyterhub Idle Culler update (#568) * Add timeout env var to culler and modify overlay * Add limits/requests to culler * Add culler timeout to jupyterhub-cfg * Add readme section --- jupyterhub/README.md | 11 +++++++ .../jupyterhub/base/jupyterhub-configmap.yaml | 1 + .../deploymentconfig.yaml | 31 ++++++++++++++++++- .../jupyterhub-idle-culler/kustomization.yaml | 4 ++- 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/jupyterhub/README.md b/jupyterhub/README.md index 2d127d7ce..8cc734e9a 100644 --- a/jupyterhub/README.md +++ b/jupyterhub/README.md @@ -74,6 +74,17 @@ Notebook Images do not provide any parameters. Notebook Images component comes with 3 overlays. +#### [jupyterhub-idle-culler](jupyterhub/overlays/jupyterhub-idle-culler) + +Adds a `DeploymentConfig` of the jupyterhub idle culler. It enables shutting down notebooks that are idle for a certain amount of time. + +Changes to the culling timeout value can either be made in the `jupyterhub-cfg` `ConfigMap` or in the cluster settings section of the ODH Dashboard. + +**Note:** The culling timeout value in the dashboard and manual configuration fo the culler will **not** work if this overlay is deployed together with the operator, as any change to the jupyterhub-cfg `ConfigMap` will be reverted. + + +Jupyterhub-idle-culler repository: https://github.com/jupyterhub/jupyterhub-idle-culler + #### [additional](notebook-images/overlays/additional/) Contains additional Jupyter notebook images. diff --git a/jupyterhub/jupyterhub/base/jupyterhub-configmap.yaml b/jupyterhub/jupyterhub/base/jupyterhub-configmap.yaml index ed8d284cd..17df6b25d 100644 --- a/jupyterhub/jupyterhub/base/jupyterhub-configmap.yaml +++ b/jupyterhub/jupyterhub/base/jupyterhub-configmap.yaml @@ -11,6 +11,7 @@ data: gpu_mode: "" singleuser_pvc_size: 2Gi notebook_destination: "$(notebook_destination)" + culler_timeout: "31536000" # 1 year in seconds --- apiVersion: v1 diff --git a/jupyterhub/jupyterhub/overlays/jupyterhub-idle-culler/deploymentconfig.yaml b/jupyterhub/jupyterhub/overlays/jupyterhub-idle-culler/deploymentconfig.yaml index d3ba3d5cc..bce3439e6 100644 --- a/jupyterhub/jupyterhub/overlays/jupyterhub-idle-culler/deploymentconfig.yaml +++ b/jupyterhub/jupyterhub/overlays/jupyterhub-idle-culler/deploymentconfig.yaml @@ -11,6 +11,23 @@ spec: labels: app: jupyterhub-idle-culler spec: + initContainers: + - name: check-for-jh + image: 'quay.io/odh-jupyterhub/jupyterhub-img:v0.3.3' + command: + - /bin/sh + - '-c' + - 'while ! curl jupyterhub:8081/hub/api; do sleep 5; done' + resources: + limits: + cpu: 150m + memory: 50Mi + requests: + cpu: 150m + memory: 20Mi + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + imagePullPolicy: IfNotPresent containers: - name: jupyterhub-idle-culler image: quay.io/odh-jupyterhub/jupyterhub-img:v0.3.5 @@ -20,9 +37,21 @@ spec: secretKeyRef: name: jupyterhub-idle-culler key: token + - name: CULLER_TIMEOUT + valueFrom: + configMapKeyRef: + name: jupyterhub-cfg + key: culler_timeout + resources: + limits: + cpu: 150m + memory: 50Mi + requests: + cpu: 150m + memory: 50Mi command: - jupyterhub-idle-culler - - --timeout=259200 # 3 days + - --timeout=$(CULLER_TIMEOUT) # in seconds - --url=jupyterhub:8081/hub/api triggers: - type: ConfigChange diff --git a/jupyterhub/jupyterhub/overlays/jupyterhub-idle-culler/kustomization.yaml b/jupyterhub/jupyterhub/overlays/jupyterhub-idle-culler/kustomization.yaml index baf673b78..2bc7848fe 100644 --- a/jupyterhub/jupyterhub/overlays/jupyterhub-idle-culler/kustomization.yaml +++ b/jupyterhub/jupyterhub/overlays/jupyterhub-idle-culler/kustomization.yaml @@ -4,5 +4,7 @@ kind: Kustomization commonLabels: app.kubernetes.io/part-of: jupyterhub +bases: + - ../../base resources: -- deploymentconfig.yaml + - ./deploymentconfig.yaml