Hi ,
Currently I am working on a usecase , where I need to introduce a side-car container inside Jupyterhub pod , which monitors /home/[username] directory of the Notebook container , for this use case I have added new container in extraContainer section of values.yaml , exactly on this line zero-to-jupyterhub-k8s/values.yaml at da8b979b982e0951bbbdc33f564ff1e33fa768b9 · jupyterhub/zero-to-jupyterhub-k8s · GitHub
But my use-case needs the new side container to mount the dynamic PV created by notebook container , I am talking about PV section here
How can this be achieved , Technically PV’s can be mounted to multiple containers , but this being a dynamic provisioned PV is creating a confusion?
manics
November 22, 2021, 11:35pm
2
Hi! It’s not clear what you’re trying to achieve.
Could you show us your full configuration file with secrets redacted, this might help clarify things.
Hi @manics , thanks for the reply , I will share snipets from my values.yaml file (single user section) and try to describe my use case here
singleuser:
extraContainers:
- name: dind
image: docker:19.03-rc-dind
lifecycle:
postStart:
exec:
command:
- "sh"
- "-c"
- "update-ca-certificates; echo Certificates Updated"
securityContext:
privileged: true
volumeMounts:
- name: dind-storage
mountPath: /var/lib/docker
- name: docker-cert
mountPath: /usr/local/share/ca-certificates/
- name: sync-service
image: private-repo/sync-service
<other section omitted from here>
static:
pvcName:
subPath: '{username}'
capacity: 10Gi
homeMountPath: '/home/{username}'
dynamic:
storageClass: nfs-client
pvcNameTemplate: claim-{username}{servername}
volumeNameTemplate: volume-{username}{servername}
storageAccessModes: [ReadWriteOnce]
Basically I want to mount /home/{username} this path in sync-service container as well.
As you can see the new PV and PVC is created exclusively for Notebook container and are never mounted on extra containers added in extraContainer section , My question is can this dynamic PV be some-how mounted on sync-service container?
I apologise , If I am unable to make my use case clear , please let me know if something is not understood or missing?
Thanks in advance…
manics
November 25, 2021, 6:58pm
4
It might be enough to add a volumeMounts and volume section that references the PersistentVolumeClaim name of dynamically created PVC. The name claim-{username}{servername}
should be expanded in extraContainers
:
extra_containers = List(
config=True,
help="""
List of containers belonging to the pod which besides to the container generated for notebook server.
This list will be directly appended under `containers` in the kubernetes pod spec,
so you should use the same structure. Each item in the list is container configuration
which follows spec at https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#container-v1-core
One usage is setting crontab in a container to clean sensitive data with configuration below::
c.KubeSpawner.extra_containers = [{
"name": "crontab",
"image": "supercronic",
"command": ["/usr/local/bin/supercronic", "/etc/crontab"]
}]
`{username}`, `{userid}`, `{servername}`, `{hubnamespace}`,
`{unescaped_username}`, and `{unescaped_servername}` will be expanded if
This file has been truncated. show original
See for example kubernetes - How can I mount the same persistent volume on multiple pods? - Stack Overflow