Add extra disks to talos-cp-2 via PostSync job, downsize memory-db to 2 instances

This commit is contained in:
Story Crater Bot
2026-08-22 23:53:01 -07:00
parent 23033bd7ef
commit 7f0f74bf30
3 changed files with 98 additions and 1 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ metadata:
annotations:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
spec:
instances: 3
instances: 2
imageName: ghcr.io/cloudnative-pg/postgresql:16.2
bootstrap:
initdb:
+1
View File
@@ -9,6 +9,7 @@ resources:
- longhorn-nodes.yaml
- expand-replicas-job.yaml
- patch-csi-tolerations-job.yaml
- longhorn-add-disks-job.yaml # Add extra disks to talos-cp-2
# Longhorn deployed via bootstrap script or Helm.
# These manifests configure it: unified StorageClass (default, 3 replicas),
# Prometheus ServiceMonitor, taint toleration for control-plane nodes, explicit
@@ -0,0 +1,96 @@
# PostSync hook Job that adds extra disks to Longhorn nodes.
# talos-cp-2 has 4 extra disks mounted at /var/lib/longhorn-disk{1,2,3,4}
# that are NOT auto-discovered by Longhorn.
apiVersion: batch/v1
kind: Job
metadata:
name: longhorn-add-disks
namespace: longhorn-system
annotations:
argocd.argoproj.io/hook: PostSync
argocd.argoproj.io/hook-delete-policy: BeforeHookCreation
spec:
backoffLimit: 3
template:
metadata:
name: longhorn-add-disks
spec:
restartPolicy: Never
serviceAccountName: longhorn-expand-replicas
containers:
- name: add-disks
image: bitnami/kubectl:latest
command:
- /bin/bash
- -c
- |
set -euo pipefail
echo "Adding extra disks to Longhorn nodes..."
# talos-cp-2 has 4 extra disks:
# - /var/lib/longhorn-disk1 (sdb1, 600GB)
# - /var/lib/longhorn-disk2 (sdc1, 500GB)
# - /var/lib/longhorn-disk3 (sdd1, 160GB)
# - /var/lib/longhorn-disk4 (sde1, 2TB)
echo "Checking talos-cp-2..."
CURRENT_DISKS=$(kubectl -n longhorn-system get nodes.longhorn.io talos-cp-2 -o json | jq -r '.spec.disks | keys | length')
echo " Current disk count: $CURRENT_DISKS"
if [ "$CURRENT_DISKS" -lt 5 ]; then
echo " Adding extra disks to talos-cp-2..."
kubectl -n longhorn-system patch nodes.longhorn.io talos-cp-2 --type merge -p '{
"spec": {
"disks": {
"disk1": {
"allowScheduling": true,
"diskType": "filesystem",
"evictionRequested": false,
"path": "/var/lib/longhorn-disk1",
"storageReserved": 10737418240,
"tags": []
},
"disk2": {
"allowScheduling": true,
"diskType": "filesystem",
"evictionRequested": false,
"path": "/var/lib/longhorn-disk2",
"storageReserved": 10737418240,
"tags": []
},
"disk3": {
"allowScheduling": true,
"diskType": "filesystem",
"evictionRequested": false,
"path": "/var/lib/longhorn-disk3",
"storageReserved": 5368709120,
"tags": []
},
"disk4": {
"allowScheduling": true,
"diskType": "filesystem",
"evictionRequested": false,
"path": "/var/lib/longhorn-disk4",
"storageReserved": 21474836480,
"tags": []
}
}
}
}'
echo " ✓ Disks added to talos-cp-2"
else
echo " ✓ talos-cp-2 already has $CURRENT_DISKS disks configured"
fi
echo
echo "Waiting for disks to be ready..."
sleep 10
echo
echo "Final storage summary:"
kubectl -n longhorn-system get nodes.longhorn.io -o json | \
jq -r '.items[] | "\(.metadata.name): \(.status.diskStatus | to_entries | map("\(.key): \(.value.storageAvailable/1073741824 | floor)GB avail") | join(", "))"'
echo
echo "Done."