Compare commits

..
Author SHA1 Message Date
kasun b04ab52fd2 Merge pull request 'Bug: Prevent Longhorn disks filling up after node outages' (#39) from bug/longhorn-storage-exhaustion into main
Deploy k8s Infra / Pulumi Preview (push) Skipped
Deploy k8s Infra / Pulumi Deploy (push) Successful in 1m4s
Reviewed-on: #39
2026-11-21 15:52:36 +01:00
kasun ff2b565677 bug(k8s-infra): prevent Longhorn disks filling up after node outages
Deploy k8s Infra / Pulumi Deploy (pull_request) Skipped
Deploy k8s Infra / Pulumi Preview (pull_request) Successful in 51s
Orphaned replica data and a large snapshot left no room for a second Prometheus replica, so the volume faulted when its only replica failed. Clean up orphans and system snapshots, trim volumes daily, and lower the free-space reserve to 10% because longhorn-extra is a dedicated disk. Align the UI default with the StorageClass at 3 replicas so volumes keep two copies during a node reboot.
2026-11-21 15:49:07 +01:00
claude-bot Bot 4b22f4ad11 Feature: Expose the Longhorn UI at longhorn.<domain> behind basic auth
Deploy k8s Infra / Pulumi Preview (push) Skipped
Deploy k8s Infra / Pulumi Deploy (push) Successful in 48s
2026-11-21 02:41:43 +01:00
+47 -1
View File
@@ -138,15 +138,61 @@ const longhorn = new k8s.helm.v3.Release(
version: "1.12.0",
values: {
defaultSettings: {
defaultReplicaCount: 2,
defaultReplicaCount: 3,
nodeDownPodDeletionPolicy: "delete-both-statefulset-and-deployment-pod",
createDefaultDiskLabeledNodes: true,
orphanResourceAutoDeletion: "replica-data;instance",
// Longhorn's recommendation for dedicated disks (longhorn-extra).
// Docs: https://longhorn.io/docs/1.12.0/best-practices/
storageMinimalAvailablePercentage: 10,
},
},
},
opts(),
);
// Purges system snapshots, which can otherwise grow to a full volume's size
// on every replica. Docs:
// https://longhorn.io/docs/1.12.0/snapshots-and-backups/scheduling-backups-and-snapshots/
new k8s.apiextensions.CustomResource(
"longhorn-snapshot-cleanup",
{
apiVersion: "longhorn.io/v1beta2",
kind: "RecurringJob",
metadata: { name: "snapshot-cleanup", namespace: "longhorn-system" },
spec: {
name: "snapshot-cleanup",
task: "snapshot-cleanup",
cron: "30 3 * * *",
groups: ["default"],
retain: 0,
concurrency: 1,
},
},
opts({ dependsOn: [longhorn] }),
);
// Returns blocks deleted inside a volume (e.g. expired Prometheus data) to the
// disk. Runs after snapshot-cleanup, since trim can't reclaim valid snapshots.
// Docs: https://longhorn.io/docs/1.12.0/nodes-and-volumes/volumes/trim-filesystem/
new k8s.apiextensions.CustomResource(
"longhorn-filesystem-trim",
{
apiVersion: "longhorn.io/v1beta2",
kind: "RecurringJob",
metadata: { name: "filesystem-trim", namespace: "longhorn-system" },
spec: {
name: "filesystem-trim",
task: "filesystem-trim",
cron: "30 4 * * *",
groups: ["default"],
retain: 0,
concurrency: 1,
},
},
opts({ dependsOn: [longhorn] }),
);
// Patches Longhorn instances to use the mountend Longhorn storage on the worker nodes.
["k3s-worker-1", "k3s-worker-2", "k3s-worker-3"].forEach(
(nodeName) =>