Add Ansible storage role for NVMe setup and Longhorn dual-disk config
Automates LV expansion, NVMe mount, and Longhorn node disk tagging (hdd/nvme) via Ansible instead of Kustomize-managed manifests.
This commit is contained in:
7
infra/ansible/inventory/host_vars/catherby.yaml
Normal file
7
infra/ansible/inventory/host_vars/catherby.yaml
Normal file
@@ -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"
|
||||||
6
infra/ansible/playbooks/storage.yaml
Normal file
6
infra/ansible/playbooks/storage.yaml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
- name: Configure storage (expand LV + mount NVMe)
|
||||||
|
hosts: k3s_cluster
|
||||||
|
become: true
|
||||||
|
roles:
|
||||||
|
- storage
|
||||||
60
infra/ansible/roles/storage/tasks/main.yaml
Normal file
60
infra/ansible/roles/storage/tasks/main.yaml
Normal file
@@ -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
|
||||||
@@ -4,4 +4,3 @@ resources:
|
|||||||
- application.yaml
|
- application.yaml
|
||||||
- namespace.yaml
|
- namespace.yaml
|
||||||
- servicemonitor.yaml
|
- servicemonitor.yaml
|
||||||
- node-disks.yaml
|
|
||||||
|
|||||||
26
infra/kubernetes/platform/longhorn/node-disks.yaml
Normal file
26
infra/kubernetes/platform/longhorn/node-disks.yaml
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user