Unable to run a lifecycle command from config.yaml while deploying jupyterhub

5/16/2019

I want to run a command as soon as a pod is created and starts running. I am deploying jupyterhub but the config that I am using is:

proxy:
  secretToken: "yada yada"
singleuser:
  image:
    # Get the latest image tag at:
    # https://hub.docker.com/r/jupyter/datascience-notebook/tags/
    # Inspect the Dockerfile at:
    # https://github.com/jupyter/docker-stacks/tree/master/datascience-notebook/Dockerfile
    name: jupyter/datascience-notebook
    # name: ${IMAGE}
    tag: 177037d09156
    # tag: latest
  lifecycle:
    postStart:
      exec:
        command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"]

When the pod is up and running, I am not able to see the file /usr/share/message and hence, I deduce that the exec command is not running.

What is the right way to make this command work?

-- Aviral Srivastava
docker
jupyter
jupyter-notebook
kubernetes
kubernetes-helm

1 Answer

5/16/2019

The correct key for lifecycle stanza is lifecyleHooks.

Following blob is with the correct values.

proxy:
  secretToken: "yada yada"
singleuser:
  image:
    # Get the latest image tag at:
    # https://hub.docker.com/r/jupyter/datascience-notebook/tags/
    # Inspect the Dockerfile at:
    # https://github.com/jupyter/docker-stacks/tree/master/datascience-notebook/Dockerfile
    name: jupyter/datascience-notebook
    # name: ${IMAGE}
    tag: 177037d09156
    # tag: latest
  lifecycleHooks:
    postStart:
      exec:
        command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"]
-- Suresh Vishnoi
Source: StackOverflow