From bcccd791484f4522d7cc7d1c83f9593ace79e5bc Mon Sep 17 00:00:00 2001 From: kasun Date: Sun, 5 Jul 2026 02:08:43 +0200 Subject: [PATCH 1/3] decreased replicas for prometheus from 3 to 2 --- 03-k8s-infra/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/03-k8s-infra/index.ts b/03-k8s-infra/index.ts index b0ccd60..e437d27 100644 --- a/03-k8s-infra/index.ts +++ b/03-k8s-infra/index.ts @@ -133,7 +133,7 @@ new k8s.apiextensions.CustomResource( version: "1.12.0", values: { defaultSettings: { - defaultReplicaCount: 3, + defaultReplicaCount: 2, podDeletionPolicyWhenNodeIsDown: "delete-pod-and-force-delete-pod", }, }, From b803ec937cd9eea9e520f278fee6d2d98bb1b09b Mon Sep 17 00:00:00 2001 From: kasun Date: Sun, 5 Jul 2026 03:45:06 +0200 Subject: [PATCH 2/3] added mounting of dedicated longhorn storage to worker nodes. --- 02-k8s-bootstrap/index.ts | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/02-k8s-bootstrap/index.ts b/02-k8s-bootstrap/index.ts index 1836e69..5732777 100644 --- a/02-k8s-bootstrap/index.ts +++ b/02-k8s-bootstrap/index.ts @@ -215,7 +215,32 @@ const joinWorker2 = new command.remote.Command( ); // --------------------------------------------------------------------------- -// Step 5: Read kubeconfig from master-1, patch server URL for external access +// Step 5: Format and mount Longhorn disks +// --------------------------------------------------------------------------- + +const workers = [worker1Ip, worker2Ip]; +const workerSshReader = [waitWorker1Ssh, waitWorker2Ssh]; + +const mountLonghornDisks = workers.map((worker, i) => { + return new command.remote.Command( + `mount-longhorn-disk-${i}`, + { + connection: conn(worker), + create: `set -euo pipefail; + DISK_ID=$(ls /dev/disk/by-id/ | grep 'scsi1'); + DISK_PATH="/dev/disk/by-id/$DISK_ID"; + sudo blkid "$DISK_PATH" >/dev/null 2>&1 || sudo mkfs.ext4 "$DISK_PATH"; + sudo mkdir -p /mnt/longhorn-extra; + echo ""$DISK_PATH" /mnt/longhorn-extra ext4 defaults,nofail 0 2" | sudo tee -a /etc/fstab; + sudo mount -a; + df -h /mnt/longhorn-extra`, + }, + { dependsOn: workerSshReader[i] }, + ); +}); + +// --------------------------------------------------------------------------- +// Step 6: Read kubeconfig from master-1, patch server URL for external access // --------------------------------------------------------------------------- const getKubeconfig = new command.remote.Command( From 135458c9acceb95efa710faf8d903cc50cbbc1a7 Mon Sep 17 00:00:00 2001 From: kasun Date: Sun, 5 Jul 2026 03:46:42 +0200 Subject: [PATCH 3/3] added patch to longhorn to use dedicated mount for longhorn to avoid using root disk and causing diskPressure --- 03-k8s-infra/index.ts | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/03-k8s-infra/index.ts b/03-k8s-infra/index.ts index e437d27..1af3eab 100644 --- a/03-k8s-infra/index.ts +++ b/03-k8s-infra/index.ts @@ -122,7 +122,7 @@ new k8s.apiextensions.CustomResource( // ── Longhorn ────────────────────────────────────────────────────────────── - new k8s.helm.v3.Release( +const longhorn = new k8s.helm.v3.Release( "longhorn", { name: "longhorn", @@ -134,13 +134,45 @@ new k8s.apiextensions.CustomResource( values: { defaultSettings: { defaultReplicaCount: 2, - podDeletionPolicyWhenNodeIsDown: "delete-pod-and-force-delete-pod", + nodeDownPodDeletionPolicy: "delete-both-statefulset-and-deployment-pod", + createDefaultDiskLabeledNodes: true, }, }, }, opts(), ); +// Patches Longhorn instances to use the mountend Longhorn storage on the worker nodes. +const workerLonghornDiskPatches = ["k3s-worker-1", "k3s-worker-2"].map( + (nodeName) => + new k8s.apiextensions.CustomResourcePatch( + `${nodeName}-longhorn-disks`, + { + apiVersion: "longhorn.io/v1beta2", + kind: "Node", + metadata: { + name: nodeName, + namespace: "longhorn-system", + annotations: { "pulumi.com/patchForce": "true" }, + }, + spec: { + disks: { + "longhorn-extra": { + allowScheduling: true, + diskDriver: "", + diskType: "filesystem", + evictionRequested: false, + path: "/mnt/longhorn-extra", + storageReserved: 0, + tags: [], + }, + }, + }, + }, + opts({ dependsOn: [longhorn] }), + ), +); + // ── kube-vip ──────────── const kubeVipNamespace = "kube-system";