Skip to content

Instantly share code, notes, and snippets.

@fabiand
Last active October 23, 2018 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabiand/e68011d2157cb3cde0116b41d1b4c463 to your computer and use it in GitHub Desktop.
Save fabiand/e68011d2157cb3cde0116b41d1b4c463 to your computer and use it in GitHub Desktop.

Overview

Components

  1. (1) trusted storage connector pod
  2. (Many) VM pods connection to storage using shared directory

Flow

  1. Get the credentials from a PVC
  2. Create a qcow2 pointing to the storage described by PV
  3. Export the qcow2 (and thus the backing storage) using nbd over a socket
  4. (Other pod) connect to the socket booting the VM

Trusted Storage Connector Pod

# Generate an image pointing to the backing store: http://docs.ceph.com/docs/giant/rbd/qemu-rbd/
# A backing store can be any storage system supported by qemu.
$ qemu-img create -f qcow2 -b rbd:$WHATVER_COMES_FROM_PV qcow-for-my-pvc.qcow2

# Now share the disk all day long
$ qemu-nbd --persistent -k /shared-nbd/my-pvc.sock $PWD/qcow-for-my-pvc.qcow2

VM

Any client can launch a VM using:

$ qemu-system-x86_64 --drive file=nbd:unix:/shared-nbd/my-pvc.sock
kind: VMI
spec:
domain:
devices:
disks:
- name: plugdisk
volumes:
plug: # This is added by a user at RUNTIME using an UPDATE rest call
name: plugdisk
persistentVolumeClaim:
claimName: the-plugged-pv
# The USER modifies the VMI
# The NDB POD is listening for volume/disk changes THEN reserves the PVC, the connects to the PV, then exports the PV over socket
# The launcher/handler is listening for volume/disk changes THEN waits for the socket to come up, then attaches (hot plugs) it to qemu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment