2018-02-15 09:55:43 +08:00
|
|
|
Local Storage Provisioner
|
|
|
|
=========================
|
2017-11-01 22:25:35 +08:00
|
|
|
|
|
|
|
The local storage provisioner is NOT a dynamic storage provisioner as you would
|
|
|
|
expect from a cloud provider. Instead, it simply creates PersistentVolumes for
|
2018-10-05 20:52:25 +08:00
|
|
|
all manually created volumes located in the directories specified in the `local_volume_provisioner_storage_classes.host_dir` entries.
|
2017-11-01 22:25:35 +08:00
|
|
|
The default path is /mnt/disks and the rest of this doc will use that path as
|
|
|
|
an example.
|
|
|
|
|
2018-02-15 09:55:43 +08:00
|
|
|
Examples to create local storage volumes
|
|
|
|
----------------------------------------
|
2017-11-01 22:25:35 +08:00
|
|
|
|
|
|
|
### tmpfs method:
|
|
|
|
|
2018-02-15 09:55:43 +08:00
|
|
|
``` bash
|
|
|
|
for vol in vol1 vol2 vol3; do
|
|
|
|
mkdir /mnt/disks/$vol
|
|
|
|
mount -t tmpfs -o size=5G $vol /mnt/disks/$vol
|
|
|
|
done
|
|
|
|
```
|
2017-11-01 22:25:35 +08:00
|
|
|
|
|
|
|
The tmpfs method is not recommended for production because the mount is not
|
|
|
|
persistent and data will be deleted on reboot.
|
|
|
|
|
|
|
|
### Mount physical disks
|
|
|
|
|
2018-02-15 09:55:43 +08:00
|
|
|
``` bash
|
|
|
|
mkdir /mnt/disks/ssd1
|
|
|
|
mount /dev/vdb1 /mnt/disks/ssd1
|
|
|
|
```
|
2017-11-01 22:25:35 +08:00
|
|
|
|
|
|
|
Physical disks are recommended for production environments because it offers
|
|
|
|
complete isolation in terms of I/O and capacity.
|
|
|
|
|
|
|
|
### File-backed sparsefile method
|
|
|
|
|
2018-02-15 09:55:43 +08:00
|
|
|
``` bash
|
|
|
|
truncate /mnt/disks/disk5 --size 2G
|
|
|
|
mkfs.ext4 /mnt/disks/disk5
|
|
|
|
mkdir /mnt/disks/vol5
|
|
|
|
mount /mnt/disks/disk5 /mnt/disks/vol5
|
|
|
|
```
|
2017-11-01 22:25:35 +08:00
|
|
|
|
|
|
|
If you have a development environment and only one disk, this is the best way
|
|
|
|
to limit the quota of persistent volumes.
|
|
|
|
|
|
|
|
### Simple directories
|
2018-02-15 09:55:43 +08:00
|
|
|
|
2018-08-10 22:14:34 +08:00
|
|
|
In a development environment using `mount --bind` works also, but there is no capacity
|
2017-11-01 22:25:35 +08:00
|
|
|
management.
|
|
|
|
|
2018-08-10 22:14:34 +08:00
|
|
|
### Block volumeMode PVs
|
|
|
|
|
|
|
|
Create a symbolic link under discovery directory to the block device on the node. To use
|
|
|
|
raw block devices in pods BlockVolume feature gate must be enabled.
|
|
|
|
|
2018-02-15 09:55:43 +08:00
|
|
|
Usage notes
|
|
|
|
-----------
|
2017-11-01 22:25:35 +08:00
|
|
|
|
2018-08-10 22:14:34 +08:00
|
|
|
Beta PV.NodeAffinity field is used by default. If running against an older K8s
|
|
|
|
version, the useAlphaAPI flag must be set in the configMap.
|
|
|
|
|
2017-11-01 22:25:35 +08:00
|
|
|
The volume provisioner cannot calculate volume sizes correctly, so you should
|
|
|
|
delete the daemonset pod on the relevant host after creating volumes. The pod
|
|
|
|
will be recreated and read the size correctly.
|
|
|
|
|
|
|
|
Make sure to make any mounts persist via /etc/fstab or with systemd mounts (for
|
|
|
|
CoreOS/Container Linux). Pods with persistent volume claims will not be
|
|
|
|
able to start if the mounts become unavailable.
|
|
|
|
|
2018-02-15 09:55:43 +08:00
|
|
|
Further reading
|
|
|
|
---------------
|
2017-11-01 22:25:35 +08:00
|
|
|
|
2018-02-15 09:55:43 +08:00
|
|
|
Refer to the upstream docs here: <https://github.com/kubernetes-incubator/external-storage/tree/master/local-volume>
|