diff --git a/infra/ansible/inventory/host_vars/catherby.yaml b/infra/ansible/inventory/host_vars/catherby.yaml new file mode 100644 index 0000000..97f4099 --- /dev/null +++ b/infra/ansible/inventory/host_vars/catherby.yaml @@ -0,0 +1,7 @@ +--- +node_labels: + - topology.kubernetes.io/zone=rack1 + - node.kubernetes.io/instance-type=nuc + +# NVMe partition UUID (Samsung 980 Pro 1TB, partition 3) +nvme_partition_uuid: "65246002-2f17-4f55-add4-a6441d484ecc" diff --git a/infra/ansible/playbooks/storage.yaml b/infra/ansible/playbooks/storage.yaml new file mode 100644 index 0000000..22713a3 --- /dev/null +++ b/infra/ansible/playbooks/storage.yaml @@ -0,0 +1,6 @@ +--- +- name: Configure storage (expand LV + mount NVMe) + hosts: k3s_cluster + become: true + roles: + - storage diff --git a/infra/ansible/roles/storage/tasks/main.yaml b/infra/ansible/roles/storage/tasks/main.yaml new file mode 100644 index 0000000..20b76db --- /dev/null +++ b/infra/ansible/roles/storage/tasks/main.yaml @@ -0,0 +1,60 @@ +--- +- name: Extend root LV to use all free VG space + community.general.lvol: + vg: ubuntu-vg + lv: ubuntu-lv + size: +100%FREE + resizefs: true + register: lv_extend + failed_when: + - lv_extend.failed + - "'matches existing size' not in (lv_extend.msg | default(''))" + +- name: Create NVMe storage mount point + ansible.builtin.file: + path: /mnt/nvme-storage + state: directory + owner: root + group: root + mode: "0755" + +- name: Mount NVMe partition + ansible.posix.mount: + path: /mnt/nvme-storage + src: UUID={{ nvme_partition_uuid }} + fstype: ext4 + opts: defaults,noatime + state: mounted + +- name: Create Longhorn data directory on NVMe + ansible.builtin.file: + path: /mnt/nvme-storage/longhorn + state: directory + owner: root + group: root + mode: "0755" + +- name: Configure Longhorn node disks (HDD + NVMe with tags) + kubernetes.core.k8s: + state: patched + api_version: longhorn.io/v1beta2 + kind: Node + name: "{{ inventory_hostname }}" + namespace: longhorn-system + definition: + spec: + disks: + default-disk-d4d0a27486e915cd: + allowScheduling: true + path: /var/lib/longhorn/ + storageReserved: 32212254720 + tags: + - hdd + nvme: + allowScheduling: true + path: /mnt/nvme-storage/longhorn/ + storageReserved: 10737418240 + tags: + - nvme + delegate_to: localhost + become: false diff --git a/infra/kubernetes/platform/longhorn/kustomization.yaml b/infra/kubernetes/platform/longhorn/kustomization.yaml index 8521a99..8e836b3 100644 --- a/infra/kubernetes/platform/longhorn/kustomization.yaml +++ b/infra/kubernetes/platform/longhorn/kustomization.yaml @@ -4,4 +4,3 @@ resources: - application.yaml - namespace.yaml - servicemonitor.yaml - - node-disks.yaml diff --git a/infra/kubernetes/platform/longhorn/node-disks.yaml b/infra/kubernetes/platform/longhorn/node-disks.yaml new file mode 100644 index 0000000..9f38264 --- /dev/null +++ b/infra/kubernetes/platform/longhorn/node-disks.yaml @@ -0,0 +1,26 @@ +# Patches the Longhorn Node to configure two disks with tags: +# - default-disk (HDD at /var/lib/longhorn/) tagged "hdd" +# - nvme-disk (NVMe at /mnt/nvme-storage/longhorn/) tagged "nvme" +# +# Apply after Longhorn is running and the NVMe is mounted: +# kubectl apply -f node-disks.yaml +apiVersion: longhorn.io/v1beta2 +kind: Node +metadata: + name: catherby + namespace: longhorn-system +spec: + allowScheduling: true + disks: + hdd: + allowScheduling: true + path: /var/lib/longhorn/ + storageReserved: 32212254720 # 30Gi reserved for system + tags: + - hdd + nvme: + allowScheduling: true + path: /mnt/nvme-storage/longhorn/ + storageReserved: 10737418240 # 10Gi reserved + tags: + - nvme