Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Directories creation inside the Kubernetes Persistent Volume

Tags:

kubernetes

How would we create a directory inside the kubernetes persistent volume to mount to use in the container as subPath ? eg: mysql directory should be created while claiming the persistent volume

like image 303
RahulKrishnan R A Avatar asked Jun 07 '17 15:06

RahulKrishnan R A


People also ask

How does the persistent volume works in Kubernetes?

Persistent volumes are independent of the lifecycle of the pod that uses it, meaning that even if the pod shuts down, the data in the volume is not erased. They are defined by an API object, which captures the implementation details of storage such as NFS file shares, or specific cloud storage systems.

What is hostPath in persistent volume?

A hostPath volume mounts a file or directory from the host node's file system into your pod. For more information about hostPath volume, see Types of Volumes . A hostPath PersistentVolume must be used only in a single-node cluster. Kubernetes does not support hostPath on a multi-node cluster currently.


1 Answers

I would probably put an init container into my podspec that simply mounts the volume and runs a mkdir -p to create the directory and then exit. You could also do this in the target container itself with some kind of script.

https://kubernetes.io/docs/concepts/workloads/pods/init-containers/

like image 161
Brett Wagner Avatar answered Sep 28 '22 05:09

Brett Wagner