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.
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?
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.
I am currently facing this issue as well, no matter whether it is postStart or preStop, even if i have a simple file creation or echo command it is just ignored. Any idea where I can start troubleshooting? I also tried adding it as an extraConfig in my hub settings as I have already created pre_spawn and post_stop hooks. So I tried adding lifecycle hooks using c.KubeSpawner.lifecycle_hooks but its ignored.
I assume it’s due to the spelling of lifecycle_hooks since the keys must match the Python trailtlets described in KubeSpawner — Kubespawner.
In addition, changing the directory via cd did not work for me, so I provided the full paths instead. Also, providing a multiline command with \ failed. So, I appended the lines with ;.
Note that echo etc won’t be seen, because the postStart hooks are starting a separate process in the container that isnt being logged to stdout etc. The only output you can get is by writing files to disk etc or having it fail - then you get an error k8s Event about it I recall.
Debugging lifecycle hooks are terrible, but make sure to be mindful of:
No feedback unless it fails, then its part of k8s Events or via kubectl describe pod i think
It runs after the container starts, so it can be too slow to create config etc to be read on startup by the containers main process.
Failure of this hook can cause pod startup failures - if i recall correctly, so it should be made very reliable