mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
* Use ConfigMaps or Endpoins for leader elections and to keep cluster state * Label pods with a postgres role * change behavior of pip install. From now on it will not install all dependencies, you have to specify explicitly DCS you want to use Patroni with: `pip install patroni[etcd,zookeeper,kubernetes]`
123 lines
2.9 KiB
YAML
123 lines
2.9 KiB
YAML
apiVersion: apps/v1beta1
|
|
kind: StatefulSet
|
|
metadata:
|
|
name: &cluster_name patronidemo
|
|
labels:
|
|
application: patroni
|
|
cluster-name: *cluster_name
|
|
spec:
|
|
replicas: 3
|
|
serviceName: *cluster_name
|
|
template:
|
|
metadata:
|
|
labels:
|
|
application: patroni
|
|
cluster-name: *cluster_name
|
|
spec:
|
|
containers:
|
|
- name: *cluster_name
|
|
image: patroni # docker build -t patroni .
|
|
imagePullPolicy: IfNotPresent
|
|
ports:
|
|
- containerPort: 8008
|
|
protocol: TCP
|
|
- containerPort: 5432
|
|
protocol: TCP
|
|
volumeMounts:
|
|
- mountPath: /home/postgres/pgdata
|
|
name: pgdata
|
|
env:
|
|
- name: POD_IP
|
|
valueFrom:
|
|
fieldRef:
|
|
fieldPath: status.podIP
|
|
- name: PATRONI_KUBERNETES_NAMESPACE
|
|
valueFrom:
|
|
fieldRef:
|
|
fieldPath: metadata.namespace
|
|
- name: PATRONI_KUBERNETES_LABELS
|
|
value: '{application: patroni, cluster-name: patronidemo}'
|
|
- name: PATRONI_SUPERUSER_USERNAME
|
|
value: postgres
|
|
- name: PATRONI_SUPERUSER_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: *cluster_name
|
|
key: superuser-password
|
|
- name: PATRONI_REPLICATION_USERNAME
|
|
value: standby
|
|
- name: PATRONI_REPLICATION_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: *cluster_name
|
|
key: replication-password
|
|
- name: PATRONI_SCOPE
|
|
value: *cluster_name
|
|
- name: PATRONI_NAME
|
|
valueFrom:
|
|
fieldRef:
|
|
fieldPath: metadata.name
|
|
- name: PATRONI_POSTGRESQL_DATA_DIR
|
|
value: /home/postgres/pgdata/pgroot/data
|
|
- name: PATRONI_POSTGRESQL_PGPASS
|
|
value: /tmp/pgpass
|
|
- name: PATRONI_POSTGRESQL_LISTEN
|
|
value: '0.0.0.0:5432'
|
|
- name: PATRONI_RESTAPI_LISTEN
|
|
value: '0.0.0.0:8008'
|
|
terminationGracePeriodSeconds: 0
|
|
volumes:
|
|
- name: pgdata
|
|
emptyDir: {}
|
|
# volumeClaimTemplates:
|
|
# - metadata:
|
|
# labels:
|
|
# application: spilo
|
|
# spilo-cluster: *cluster_name
|
|
# annotations:
|
|
# volume.alpha.kubernetes.io/storage-class: anything
|
|
# name: pgdata
|
|
# spec:
|
|
# accessModes:
|
|
# - ReadWriteOnce
|
|
# resources:
|
|
# requests:
|
|
# storage: 5Gi
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: Endpoints
|
|
metadata:
|
|
name: &cluster_name patronidemo
|
|
labels:
|
|
application: patroni
|
|
cluster-name: *cluster_name
|
|
subsets: []
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: &cluster_name patronidemo
|
|
labels:
|
|
application: patroni
|
|
cluster-name: *cluster_name
|
|
spec:
|
|
type: ClusterIP
|
|
ports:
|
|
- port: 5432
|
|
targetPort: 5432
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: Secret
|
|
metadata:
|
|
name: &cluster_name patronidemo
|
|
labels:
|
|
application: patroni
|
|
cluster-name: *cluster_name
|
|
type: Opaque
|
|
data:
|
|
superuser-password: emFsYW5kbw==
|
|
replication-password: cmVwLXBhc3M=
|