【问题标题】:How to create a file while creating(claiming) persistent volume?如何在创建(声明)持久卷时创建文件?
【发布时间】:2019-05-16 10:51:22
【问题描述】:

我想在某个路径创建一个文件。正在使用的 docker 镜像来自文件:

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
    tag: 177037d09156

以上yaml取自这里:https://zero-to-jupyterhub.readthedocs.io/en/latest/user-environment.html

JuPyterHub 为方案 singleUser 中的每个用户创建一个新 pod。我想在创建新卷后立即创建一个文件。

我尝试阅读文档和其他相关问题,但没有一个解决这个问题。

下面是定义存储逻辑的sn-p。每个用户都有一个新的 pvc,我想在这个 pvc 中创建一个新文件,只要它被创建。我在下面的代码 sn-p 中已经有了 homeMountPath 和用户名,我不知道如何编写文件 - 类似于:echo "run_id = 'sample' " > /home/jovyan/username/.ipython/profile_default/startup/aviral.py

storage:
    type: dynamic
    extraLabels: {}
    extraVolumes: []
    extraVolumeMounts: []
    static:
      pvcName:
      subPath: '{username}'
    capacity: 10Gi
    homeMountPath: /home/jovyan
    dynamic:
      storageClass:
      pvcNameTemplate: claim-{username}{servername}
      volumeNameTemplate: volume-{username}{servername}
      storageAccessModes: [ReadWriteOnce]

完整的舵图在这里,官方:https://jupyterhub.github.io/helm-chart/jupyterhub-0.8.2.tgz

我希望在命名空间 jhub 中创建的 pod 已经创建了一个文件。

【问题讨论】:

    标签: docker kubernetes jupyter-notebook jupyter kubernetes-helm


    【解决方案1】:

    您可以查看 configmap 对象。来自 configmap 的文件可以作为卷挂载在容器内。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-05-22
      • 1970-01-01
      • 2017-02-27
      • 2020-11-10
      • 1970-01-01
      • 1970-01-01
      • 2016-10-10
      相关资源
      最近更新 更多