PostgreSQL FAQs
1. Use ETCD as Patroni DCS
KubeBlocks PostgreSQL uses the Kubernetes API itself as DCS (Distributed Config Store) by default.
But when the control plane is under extreme high load, it may lead to unexpected demotion of the primary replica. And it's recommended to use ETCD as DCS in such extreme cases.
apiVersion: apps.kubeblocks.io/v1
kind: Cluster
metadata:
name: pg-cluster-etcd
namespace: demo
spec:
terminationPolicy: Delete
clusterDef: postgresql
topology: replication
componentSpecs:
- name: postgresql
serviceVersion: "16.4.0"
env:
- name: DCS_ENABLE_KUBERNETES_API
- name: ETCD3_HOST
value: 'etcd-cluster-etcd-headless.demo.svc.cluster.local:2379'
replicas: 2
resources:
limits:
cpu: "0.5"
memory: "0.5Gi"
requests:
cpu: "0.5"
memory: "0.5Gi"
volumeClaimTemplates:
- name: data
spec:
storageClassName: ""
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
The key fields are:
DCS_ENABLE_KUBERNETES_API
: Unset this env to use ETCD or ZooKeeper as DCS
ETCD3_HOST
: The host of ETCD cluster
You can also use ZooKeeper as DCS by unsetting DCS_ENABLE_KUBERNETES_API
and setting ZOOKEEPER_HOSTS
to the host of ZooKeeper cluster.
KubeBlocks has ETCD and ZooKeeper Addons in the kubeblocks-addons
repository. You can refer to the following links for more details.
You can shell into one of the etcd container to view the etcd data, and view the etcd data with etcdctl.
etcdctl get /service --prefix