kubernetes 部署jupyterhub时无法从config.yaml运行生命周期命令

gmxoilav  于 2022-12-11  发布在  Kubernetes
关注(0)|答案(2)|浏览(145)

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?

7qhs6swi

7qhs6swi1#

生命周期节的正确关键字是lifecyleHooks

以下Blob具有正确的值。

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"]
2exbekwf

2exbekwf2#

您可以使用“lifecycleHooks”将其写出,如下所示。
请注意,这也可以用于多个命令,方法是添加以“;“
您可以在“echo”命令之后添加额外的命令。

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;

相关问题