lifecycleHooks not launching on Jupyterhub kubernetes

When defining a postStart lifecycle hook for singleuser pods in the Helm chart values, placing the hook inside the singleuser block causes it to be silently ignored. Even though the value is syntactically valid YAML.

singleuser:
      lifecycleHooks:
        postStart:
          exec:
            command:
              - "sh"
              - "-c"
              - >
                git config --global credential.helper store;

My goal is to pull gitlab repository through the start of my notebooks and I’m using Keycloak Auth

I’m using the bitnami charts with an app_version “4.0.2”

I’m using the bitnami charts with an app_version “4.0.2”

Is the bitnami charts respecting config structured like that? That seems like the official JupyterHub charts config structure – maybe you are using an example from that chart instead of bitnami’s jupyterhub chart?

1 Like

Thank you for your response.

Yes, But I checked on the bitnami values conf.
They using the same file structure

{{- if .Values.singleuser.lifecycleHooks }}
      lifecycleHooks: {{- include "common.tplvalues.render" ( dict "value" .Values.singleuser.lifecycleHooks "context" $ ) | nindent 4 }}
      {{- end }}

charts/bitnami/jupyterhub/values.yaml at main · bitnami/charts

Can you try reproducing this with the Z2JH Helm chart
https://z2jh.jupyter.org/en/stable/jupyterhub/installation.html#install-jupyterhub

If it’s reproducible please share your full configuration, and the output of kubectl get pod <singleuser-pod> -o yaml

2 Likes

Lifecycle hooks for “singleuser” should result in configuration of KubeSpawner. What is rendered by helm templates must therefore be considered via a jupyterhub config file, in order to configure kubespawner’s config on how to construct the pod to have a lifecycle hook.

Maybe the bitnami chart fails to do that part?

I checked on the jupyterhub_config.py and I found we are laso using the KubeSpawner

It’s the same conf between the bitnami & the official chart. c.JupyterHub.spawner_class = "kubespawner.KubeSpawner"

So If I understood the lifecyclehooks is mapped to c.KubeSpawner.lifecycle_hooks

If you still need help please see my earlier comment about reproducing this with the official Z2JH Helm chart, and giving us the pod YAML.