Storage on several machines

An install on several machines keeps its shared data on Ceph, which Rook runs on the machines themselves. Each machine keeps all of its storage in one ZFS pool: Ceph's disk, the volumes that stay on that machine, and what the system writes. Make the pool by hand on each machine, before the platform starts Ceph there.

The layout

Each machine has the same layout:

Part Where Holds
The system its own partitions on the fast disk the Gingko OS, read-only
Data vdevs the slow, large disks, striped Ceph's data, and large local volumes
Special vdev most of the fast disk every dataset's metadata, and the datasets that ask for it
Log vdev a few GB of the fast disk the pool's synchronous writes

The pool has no mirror and no RAID-Z. Ceph keeps three copies of the shared data on three machines, and a database keeps its replica on another machine. When a disk fails, that machine's pool is lost, and the other machines still have every copy.

So a local volume holds only what survives the loss of its machine's pool:

Keep everything else on Ceph.

Make the key

The pool is encrypted. Its key is a file the machine reads at boot, so it starts without help.

Where the file goes depends on whether the machine has a TPM 2.0:

Use a machine with a TPM 2.0 when you can choose. Without a TPM:

dd if=/dev/urandom of=/oem/gingko-pool.key bs=32 count=1
chmod 400 /oem/gingko-pool.key

Copy the key to your password manager. Without it, nobody can read the pool.

Make the pool

Name each disk by a path that does not change, from /dev/disk/by-id. In this example the pool is gko, the two slow disks are hdd-a and hdd-b, and the fast disk's partitions for the special and log vdevs are nvme-part5 and nvme-part6:

zpool create -o ashift=12 \
  -O mountpoint=none -O compression=lz4 \
  -O encryption=aes-256-gcm -O keyformat=raw \
  -O keylocation=file:///oem/gingko-pool.key \
  gko /dev/disk/by-id/hdd-a /dev/disk/by-id/hdd-b \
  special /dev/disk/by-id/nvme-part5 \
  log /dev/disk/by-id/nvme-part6

With a TPM, keylocation names the key's path under /usr/local instead. Every dataset and volume in the pool inherits the encryption.

Make the datasets

A dataset goes on the fast disk when its special_small_blocks is equal to or larger than its block size. The system's datasets go there:

for d in rancher:/var/lib/rancher kubelet:/var/lib/kubelet cni:/var/lib/cni log:/var/log; do
  zfs create -u -o special_small_blocks=128K -o mountpoint=${d#*:} gko/${d%%:*}
done

The platform's dataset is <pool>/<domain>. Make it, and the three parents under it that the storage classes use:

zfs create gko/example.org
zfs create -o special_small_blocks=128K gko/example.org/fast
zfs create -o primarycache=metadata -o secondarycache=none \
  -o logbias=throughput gko/example.org/osd-data
zfs create -o special_small_blocks=16K gko/example.org/osd-db
Dataset Used by
fast the local-fast class: volumes on the fast disk, for databases
osd-data Ceph's data, a volume that grows as Ceph writes
osd-db Ceph's metadata, on the fast disk

Tell the OS

In the cloud-config, name the pool so that the OS loads its key and imports it at each boot, and limit how much memory ZFS keeps for its cache. ZFS takes most of the memory when nothing limits it.

stages:
  initramfs:
    - files:
        - path: /etc/conf.d/gingko-pool
          content: pool=gko
        - path: /etc/modprobe.d/zfs.conf
          content: options zfs zfs_arc_max=4294967296

Tell the platform

Label each machine that has its pool, so that Ceph puts a disk there:

kubectl label node <machine> gingko.garden/zfs-pool=true

Then set the platform's values: the dataset, and one Ceph disk for each labelled machine.

platform:
  zfs:
    dataset: gko/example.org
  rook:
    enabled: true
    zfsOsds:
      count: 3

The Checks tab shows a pool that is more than 80% full. Ceph's data and the local volumes share the pool, so it can fill before Ceph reports that it is full.


Last validated: · View as Markdown