252 lines
8.8 KiB
YAML
252 lines
8.8 KiB
YAML
# Source: gitea/charts/postgresql-ha/templates/postgresql/statefulset.yaml
|
|
apiVersion: apps/v1
|
|
kind: StatefulSet
|
|
metadata:
|
|
name: release-name-postgresql-ha-postgresql
|
|
namespace: "gitea"
|
|
labels:
|
|
app.kubernetes.io/instance: release-name
|
|
app.kubernetes.io/name: postgresql-ha
|
|
app.kubernetes.io/version: 16.3.0
|
|
app.kubernetes.io/component: postgresql
|
|
role: data
|
|
spec:
|
|
replicas: 3
|
|
podManagementPolicy: "Parallel"
|
|
serviceName: release-name-postgresql-ha-postgresql-headless
|
|
updateStrategy:
|
|
type: RollingUpdate
|
|
selector:
|
|
matchLabels:
|
|
app.kubernetes.io/instance: release-name
|
|
app.kubernetes.io/name: postgresql-ha
|
|
app.kubernetes.io/component: postgresql
|
|
role: data
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app.kubernetes.io/instance: release-name
|
|
app.kubernetes.io/name: postgresql-ha
|
|
app.kubernetes.io/version: 16.3.0
|
|
app.kubernetes.io/component: postgresql
|
|
role: data
|
|
spec:
|
|
nodeSelector:
|
|
nodegroup: nd
|
|
automountServiceAccountToken: false
|
|
affinity:
|
|
podAffinity:
|
|
|
|
podAntiAffinity:
|
|
preferredDuringSchedulingIgnoredDuringExecution:
|
|
- podAffinityTerm:
|
|
labelSelector:
|
|
matchLabels:
|
|
app.kubernetes.io/instance: release-name
|
|
app.kubernetes.io/name: postgresql-ha
|
|
app.kubernetes.io/component: postgresql
|
|
topologyKey: kubernetes.io/hostname
|
|
weight: 1
|
|
nodeAffinity:
|
|
|
|
securityContext:
|
|
fsGroup: 1001
|
|
fsGroupChangePolicy: Always
|
|
supplementalGroups: []
|
|
sysctls: []
|
|
serviceAccountName: release-name-postgresql-ha
|
|
hostNetwork: false
|
|
hostIPC: false
|
|
containers:
|
|
- name: postgresql
|
|
image: docker.io/bitnami/postgresql-repmgr:16.3.0-debian-12-r15
|
|
imagePullPolicy: "IfNotPresent"
|
|
securityContext:
|
|
allowPrivilegeEscalation: false
|
|
capabilities:
|
|
drop:
|
|
- ALL
|
|
privileged: false
|
|
readOnlyRootFilesystem: true
|
|
runAsGroup: 1001
|
|
runAsNonRoot: true
|
|
runAsUser: 1001
|
|
seccompProfile:
|
|
type: RuntimeDefault
|
|
lifecycle:
|
|
preStop:
|
|
exec:
|
|
command:
|
|
- /pre-stop.sh
|
|
- "25"
|
|
# Auxiliary vars to populate environment variables
|
|
env:
|
|
- name: BITNAMI_DEBUG
|
|
value: "false"
|
|
# PostgreSQL configuration
|
|
- name: POSTGRESQL_VOLUME_DIR
|
|
value: "/bitnami/postgresql"
|
|
- name: PGDATA
|
|
value: "/bitnami/postgresql/data"
|
|
- name: POSTGRES_POSTGRES_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: release-name-postgresql-ha-postgresql
|
|
key: postgres-password
|
|
- name: POSTGRES_USER
|
|
value: "gitea"
|
|
- name: POSTGRES_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: release-name-postgresql-ha-postgresql
|
|
key: password
|
|
- name: POSTGRES_DB
|
|
value: "gitea"
|
|
- name: POSTGRESQL_LOG_HOSTNAME
|
|
value: "true"
|
|
- name: POSTGRESQL_LOG_CONNECTIONS
|
|
value: "false"
|
|
- name: POSTGRESQL_LOG_DISCONNECTIONS
|
|
value: "false"
|
|
- name: POSTGRESQL_PGAUDIT_LOG_CATALOG
|
|
value: "off"
|
|
- name: POSTGRESQL_CLIENT_MIN_MESSAGES
|
|
value: "error"
|
|
- name: POSTGRESQL_SHARED_PRELOAD_LIBRARIES
|
|
value: "pgaudit, repmgr"
|
|
- name: POSTGRESQL_ENABLE_TLS
|
|
value: "no"
|
|
- name: POSTGRESQL_PORT_NUMBER
|
|
value: "5432"
|
|
# Repmgr configuration
|
|
- name: REPMGR_PORT_NUMBER
|
|
value: "5432"
|
|
- name: REPMGR_PRIMARY_PORT
|
|
value: "5432"
|
|
- name: MY_POD_NAME
|
|
valueFrom:
|
|
fieldRef:
|
|
fieldPath: metadata.name
|
|
- name: REPMGR_UPGRADE_EXTENSION
|
|
value: "no"
|
|
- name: REPMGR_PGHBA_TRUST_ALL
|
|
value: "no"
|
|
- name: REPMGR_MOUNTED_CONF_DIR
|
|
value: "/bitnami/repmgr/conf"
|
|
- name: REPMGR_NAMESPACE
|
|
valueFrom:
|
|
fieldRef:
|
|
fieldPath: metadata.namespace
|
|
- name: REPMGR_PARTNER_NODES
|
|
value: release-name-postgresql-ha-postgresql-0.release-name-postgresql-ha-postgresql-headless.$(REPMGR_NAMESPACE).svc.cluster.local,release-name-postgresql-ha-postgresql-1.release-name-postgresql-ha-postgresql-headless.$(REPMGR_NAMESPACE).svc.cluster.local,release-name-postgresql-ha-postgresql-2.release-name-postgresql-ha-postgresql-headless.$(REPMGR_NAMESPACE).svc.cluster.local,
|
|
- name: REPMGR_PRIMARY_HOST
|
|
value: "release-name-postgresql-ha-postgresql-0.release-name-postgresql-ha-postgresql-headless.$(REPMGR_NAMESPACE).svc.cluster.local"
|
|
- name: REPMGR_NODE_NAME
|
|
value: "$(MY_POD_NAME)"
|
|
- name: REPMGR_NODE_NETWORK_NAME
|
|
value: "$(MY_POD_NAME).release-name-postgresql-ha-postgresql-headless.$(REPMGR_NAMESPACE).svc.cluster.local"
|
|
- name: REPMGR_NODE_TYPE
|
|
value: "data"
|
|
- name: REPMGR_LOG_LEVEL
|
|
value: "NOTICE"
|
|
- name: REPMGR_CONNECT_TIMEOUT
|
|
value: "5"
|
|
- name: REPMGR_RECONNECT_ATTEMPTS
|
|
value: "2"
|
|
- name: REPMGR_RECONNECT_INTERVAL
|
|
value: "3"
|
|
- name: REPMGR_USERNAME
|
|
value: "repmgr"
|
|
- name: REPMGR_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: release-name-postgresql-ha-postgresql
|
|
key: repmgr-password
|
|
- name: REPMGR_DATABASE
|
|
value: "repmgr"
|
|
- name: REPMGR_FENCE_OLD_PRIMARY
|
|
value: "no"
|
|
- name: REPMGR_CHILD_NODES_CHECK_INTERVAL
|
|
value: "5"
|
|
- name: REPMGR_CHILD_NODES_CONNECTED_MIN_COUNT
|
|
value: "1"
|
|
- name: REPMGR_CHILD_NODES_DISCONNECT_TIMEOUT
|
|
value: "30"
|
|
envFrom:
|
|
ports:
|
|
- name: postgresql
|
|
containerPort: 5432
|
|
protocol: TCP
|
|
livenessProbe:
|
|
failureThreshold: 6
|
|
initialDelaySeconds: 30
|
|
periodSeconds: 10
|
|
successThreshold: 1
|
|
timeoutSeconds: 5
|
|
exec:
|
|
command:
|
|
- bash
|
|
- -ec
|
|
- 'PGPASSWORD=$POSTGRES_PASSWORD psql -w -U "gitea" -d "gitea" -h 127.0.0.1 -p 5432 -c "SELECT 1"'
|
|
readinessProbe:
|
|
failureThreshold: 6
|
|
initialDelaySeconds: 5
|
|
periodSeconds: 10
|
|
successThreshold: 1
|
|
timeoutSeconds: 5
|
|
exec:
|
|
command:
|
|
- bash
|
|
- -ec
|
|
- |
|
|
exec pg_isready -U "postgres" -h 127.0.0.1 -p 5432
|
|
[ -f /opt/bitnami/postgresql/tmp/.initialized ] || [ -f /bitnami/postgresql/.initialized ]
|
|
resources:
|
|
limits:
|
|
cpu: 375m
|
|
ephemeral-storage: 2Gi
|
|
memory: 384Mi
|
|
requests:
|
|
cpu: 250m
|
|
ephemeral-storage: 50Mi
|
|
memory: 256Mi
|
|
volumeMounts:
|
|
- name: empty-dir
|
|
mountPath: /tmp
|
|
subPath: tmp-dir
|
|
- name: empty-dir
|
|
mountPath: /opt/bitnami/postgresql/conf
|
|
subPath: app-conf-dir
|
|
- name: empty-dir
|
|
mountPath: /opt/bitnami/postgresql/tmp
|
|
subPath: app-tmp-dir
|
|
- name: empty-dir
|
|
mountPath: /opt/bitnami/repmgr/conf
|
|
subPath: repmgr-conf-dir
|
|
- name: empty-dir
|
|
mountPath: /opt/bitnami/repmgr/tmp
|
|
subPath: repmgr-tmp-dir
|
|
- name: empty-dir
|
|
mountPath: /opt/bitnami/repmgr/logs
|
|
subPath: repmgr-logs-dir
|
|
- name: data
|
|
mountPath: /bitnami/postgresql
|
|
subPathExpr: $(MY_POD_NAME)
|
|
- name: hooks-scripts
|
|
mountPath: /pre-stop.sh
|
|
subPath: pre-stop.sh
|
|
- name: hooks-scripts
|
|
mountPath: /readiness-probe.sh
|
|
subPath: readiness-probe.sh
|
|
volumes:
|
|
- name: empty-dir
|
|
emptyDir: {}
|
|
- name: hooks-scripts
|
|
configMap:
|
|
name: release-name-postgresql-ha-postgresql-hooks-scripts
|
|
defaultMode: 0755
|
|
- name: data
|
|
hostPath:
|
|
path: /data
|
|
type: DirectoryOrCreate
|