From e62baff9e7d439a375fee4af8b366f14947d439d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Limpinho?= <53994778+TomasLimpinho@users.noreply.github.com> Date: Mon, 10 Nov 2025 23:13:36 +0000 Subject: [PATCH] stolon --- roles/stolon/files/stolon-keeper.yaml | 36 ++++++--- roles/stolon/files/stolon-pvcs.yaml | 111 ++++++++++++++++++++++++++ 2 files changed, 135 insertions(+), 12 deletions(-) create mode 100644 roles/stolon/files/stolon-pvcs.yaml diff --git a/roles/stolon/files/stolon-keeper.yaml b/roles/stolon/files/stolon-keeper.yaml index 83d8a99..fdbffda 100644 --- a/roles/stolon/files/stolon-keeper.yaml +++ b/roles/stolon/files/stolon-keeper.yaml @@ -33,22 +33,32 @@ spec: - "/bin/bash" - "-ec" - | + + echo "COMECANDO com user 1013" + useradd -u 1013 -r -s /usr/sbin/nologin fenixuser + id id stolon - id root # Generate our keeper uid using the pod index IFS='-' read -ra ADDR <<< "$(hostname)" export STKEEPER_UID="keeper${ADDR[-1]}" export POD_IP=$(hostname -i) export STKEEPER_PG_LISTEN_ADDRESS=$POD_IP - mkdir -p /stolon-data/data + + which psql + which postgres + which pg_ctl + + export STOLON_DATA=/stolon-data/data - chown root:root /stolon-data - chown root:root $STOLON_DATA - exec gosu root stolon-keeper --data-dir $STOLON_DATA - securityContext: - runAsUser: 0 - runAsGroup: 0 - allowPrivilegeEscalation: true + mkdir -p $STOLON_DATA + + + ls -la $STOLON_DATA + + exec gosu 1013 stolon-keeper --data-dir $STOLON_DATA + + + env: - name: POD_NAME valueFrom: @@ -92,7 +102,7 @@ spec: - containerPort: 8080 volumeMounts: - mountPath: /stolon-data - name: data + name: stolon-data - mountPath: /etc/secrets/stolon name: stolon volumes: @@ -103,7 +113,7 @@ spec: - kind: PersistentVolumeClaim apiVersion: v1 metadata: - name: data + name: stolon-data namespace: postgresql spec: accessModes: @@ -111,4 +121,6 @@ spec: resources: requests: storage: 10Gi - storageClassName: stolon-nfs-csi \ No newline at end of file + selector: + matchLabels: + postgres-id: "stolon-0" \ No newline at end of file diff --git a/roles/stolon/files/stolon-pvcs.yaml b/roles/stolon/files/stolon-pvcs.yaml new file mode 100644 index 0000000..2eb49cf --- /dev/null +++ b/roles/stolon/files/stolon-pvcs.yaml @@ -0,0 +1,111 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: stolon-pv-0 + namespace: postgresql + labels: + postgres-id: "stolon-0" +spec: + capacity: + storage: 10Gi + storageClassName: stolon-nfs-csi + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Retain + nfs: + server: 192.168.1.22 + path: /mnt/fenix-main-nas-pool-0/data/k8s-Volumes/k8s-cluster-iac-deployed/postgresql-stolon/keeper-0 +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: stolon-pv-1 + namespace: postgresql + labels: + postgres-id: "stolon-0" +spec: + capacity: + storage: 10Gi + storageClassName: stolon-nfs-csi + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Retain + nfs: + server: 192.168.1.22 + path: /mnt/fenix-main-nas-pool-0/data/k8s-Volumes/k8s-cluster-iac-deployed/postgresql-stolon/keeper-1 +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: stolon-pv-2 + namespace: postgresql + labels: + postgres-id: "stolon-0" +spec: + capacity: + storage: 10Gi + storageClassName: stolon-nfs-csi + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Retain + nfs: + server: 192.168.1.22 + path: /mnt/fenix-main-nas-pool-0/data/k8s-Volumes/k8s-cluster-iac-deployed/postgresql-stolon/keeper-2 +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: stolon-data-stolon-keeper-0 + namespace: postgresql + labels: + postgres-id: "stolon-0" +spec: + storageClassName: stolon-nfs-csi + accessModes: + - ReadWriteOnce + volumeName: stolon-pv-0 + resources: + requests: + storage: 10Gi + selector: + matchLabels: + postgres-id: "stolon-0" +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: stolon-data-stolon-keeper-1 + namespace: postgresql + labels: + postgres-id: "stolon-0" +spec: + storageClassName: stolon-nfs-csi + accessModes: + - ReadWriteOnce + volumeName: stolon-pv-1 + resources: + requests: + storage: 10Gi + selector: + matchLabels: + postgres-id: "stolon-0" +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: stolon-data-stolon-keeper-2 + namespace: postgresql + labels: + postgres-id: "stolon-0" +spec: + storageClassName: stolon-nfs-csi + accessModes: + - ReadWriteOnce + volumeName: stolon-pv-2 + resources: + requests: + storage: 10Gi + selector: + matchLabels: + postgres-id: "stolon-0" +--- \ No newline at end of file