Merge "Dynamically determine disk for images & bindmounts"

This commit is contained in:
Zuul 2020-09-03 12:28:32 +00:00 committed by Gerrit Code Review
commit ea56139335

View File

@ -106,15 +106,30 @@ stringData:
path: /tmp/kubeadm.yaml path: /tmp/kubeadm.yaml
permissions: "0640" permissions: "0640"
bootcmd: bootcmd:
- /usr/sbin/mkfs.ext4 /dev/vda - NEED_MB=16384 # MB of storage needed for ironic images & bindmounts
- mkdir /mnt/vda - FREE_MB=$(df -m --output=avail /var/lib | tail -n 1)
- mount /dev/vda /mnt/vda # if there's not enough memory-backed storage, mount an available disk
- if [ ${FREE_MB} -lt ${NEED_MB} ]; then
- mkdir /mnt/ephemeral
# Use vda if provided by a hypervisor
- if [ -e /dev/vda ]; then
- mkfs.ext4 /dev/vda
- mount /dev/vda /mnt/ephemeral
# Fall back to sda
- elif [ -e /dev/sda ]; then
- mkfs.ext4 -F /dev/sda
- mount /dev/sda /mnt/ephemeral
- else
- echo "Not enough RAM to host images, and no available disks found"
- exit 1
- fi
- mkdir -p /opt/metal3-dev-env/ironic/html/images - mkdir -p /opt/metal3-dev-env/ironic/html/images
- mkdir -p /mnt/vda/opt/metal3-dev-env/ironic/html/images - mkdir -p /mnt/ephemeral/opt/metal3-dev-env/ironic/html/images
- mount --bind /mnt/vda/opt/metal3-dev-env/ironic/html/images /opt/metal3-dev-env/ironic/html/images - mount --bind /mnt/ephemeral/opt/metal3-dev-env/ironic/html/images /opt/metal3-dev-env/ironic/html/images
- mkdir -p /var/lib/docker /mnt/vda/var/lib/docker - mkdir -p /var/lib/docker /mnt/ephemeral/var/lib/docker
- mount --bind /mnt/vda/var/lib/docker /var/lib/docker - mount --bind /mnt/ephemeral/var/lib/docker /var/lib/docker
- mkdir -p /var/lib/docker-engine /mnt/vda/var/lib/docker-engine - mkdir -p /var/lib/docker-engine /mnt/ephemeral/var/lib/docker-engine
- mount --bind /mnt/vda/var/lib/docker-engine /var/lib/docker-engine - mount --bind /mnt/ephemeral/var/lib/docker-engine /var/lib/docker-engine
- mkdir -p /mnt/vda/var/lib/kubelet/ /var/lib/kubelet/ - mkdir -p /mnt/ephemeral/var/lib/kubelet/ /var/lib/kubelet/
- mount --bind /mnt/vda/var/lib/kubelet/ /var/lib/kubelet/ - mount --bind /mnt/ephemeral/var/lib/kubelet/ /var/lib/kubelet/
- fi