|
| 1 | +apiVersion: apps/v1 |
| 2 | +kind: StatefulSet |
| 3 | +metadata: |
| 4 | + name: postgres |
| 5 | + labels: |
| 6 | + app.kubernetes.io/name: postgres |
| 7 | + app.kubernetes.io/instance: postgres |
| 8 | +spec: |
| 9 | + replicas: 1 |
| 10 | + selector: |
| 11 | + matchLabels: |
| 12 | + app.kubernetes.io/name: postgres |
| 13 | + app.kubernetes.io/instance: postgres |
| 14 | + template: |
| 15 | + metadata: |
| 16 | + labels: |
| 17 | + app.kubernetes.io/name: postgres |
| 18 | + app.kubernetes.io/instance: postgres |
| 19 | + spec: |
| 20 | + securityContext: |
| 21 | + runAsNonRoot: true |
| 22 | + runAsUser: 999 |
| 23 | + runAsGroup: 999 |
| 24 | + fsGroup: 999 |
| 25 | + terminationGracePeriodSeconds: 60 |
| 26 | + initContainers: |
| 27 | + - name: import-base |
| 28 | + image: ghcr.io/codestation/pgbackrest:2.54.2-postgres17 |
| 29 | + command: |
| 30 | + - bash |
| 31 | + - -c |
| 32 | + - /scripts/restore.sh |
| 33 | + envFrom: |
| 34 | + - configMapRef: |
| 35 | + name: pgbackrest-config |
| 36 | + - configMapRef: |
| 37 | + name: postgres-config |
| 38 | + volumeMounts: |
| 39 | + - name: pgdata |
| 40 | + mountPath: /var/lib/postgresql/data |
| 41 | + - name: pgbackrest-scripts |
| 42 | + mountPath: /scripts |
| 43 | + - name: pgbackrest-files |
| 44 | + mountPath: /defaults |
| 45 | + - name: pgbackrest-certs |
| 46 | + mountPath: /certs |
| 47 | + containers: |
| 48 | + - name: postgres |
| 49 | + image: ghcr.io/codestation/postgres:17 |
| 50 | + command: ["docker-entrypoint.sh"] |
| 51 | + args: ["postgres"] |
| 52 | + envFrom: |
| 53 | + - configMapRef: |
| 54 | + name: postgres-config |
| 55 | + - configMapRef: |
| 56 | + name: pgbackrest-config |
| 57 | + - secretRef: |
| 58 | + name: postgres-secret |
| 59 | + optional: true |
| 60 | + env: |
| 61 | + - name: POSTGRES_USER |
| 62 | + valueFrom: |
| 63 | + secretKeyRef: |
| 64 | + name: postgres-root-credentials |
| 65 | + key: username |
| 66 | + - name: POSTGRES_PASSWORD |
| 67 | + valueFrom: |
| 68 | + secretKeyRef: |
| 69 | + name: postgres-root-credentials |
| 70 | + key: password |
| 71 | + ports: |
| 72 | + - containerPort: 5432 |
| 73 | + name: postgres |
| 74 | + lifecycle: |
| 75 | + preStop: |
| 76 | + exec: |
| 77 | + command: |
| 78 | + - sh |
| 79 | + - -c |
| 80 | + - exec pg_ctl stop -D /var/lib/postgresql/data -m fast -w -t 60 |
| 81 | + volumeMounts: |
| 82 | + - name: pgdata |
| 83 | + mountPath: /var/lib/postgresql/data |
| 84 | + - name: shm |
| 85 | + mountPath: /dev/shm |
| 86 | + - name: pgbackrest-spooler |
| 87 | + mountPath: /var/spool/pgbackrest |
| 88 | + - name: postgres-scripts |
| 89 | + mountPath: /docker-entrypoint-initdb.d |
| 90 | + - name: pgbackrest-certs |
| 91 | + mountPath: /certs |
| 92 | + volumes: |
| 93 | + - name: pgdata |
| 94 | + persistentVolumeClaim: |
| 95 | + claimName: postgres-pvc |
| 96 | + - name: shm |
| 97 | + emptyDir: |
| 98 | + medium: Memory |
| 99 | + - name: postgres-scripts |
| 100 | + configMap: |
| 101 | + name: postgres-scripts |
| 102 | + defaultMode: 0755 |
| 103 | + - name: pgbackrest-spooler |
| 104 | + emptyDir: {} |
| 105 | + - name: pgbackrest-scripts |
| 106 | + configMap: |
| 107 | + name: pgbackrest-scripts |
| 108 | + defaultMode: 0755 |
| 109 | + - name: pgbackrest-files |
| 110 | + configMap: |
| 111 | + name: pgbackrest-files |
| 112 | + defaultMode: 0600 |
| 113 | + - name: pgbackrest-certs |
| 114 | + projected: |
| 115 | + defaultMode: 0600 |
| 116 | + sources: |
| 117 | + - secret: |
| 118 | + name: pgbackrest-certs |
0 commit comments