官网
https://github.com/CrunchyData/postgres-operator-examples
https://access.crunchydata.com/documentation/postgres-operator/v5/
一些基本修改
1 | cd postgres-operator-examples |
指定 namespace 为 postgres-operator
kubectl apply -k kustomize/install/namespace
创建 namespace1
2
3
4apiVersion: v1
kind: Namespace
metadata:
name: postgres-operator
kubectl apply --server-side -k kustomize/install/default
一般只用修改镜像,没什么大的调整1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25namespace: postgres-operator
commonLabels:
app.kubernetes.io/name: pgo
# The version below should match the version on the PostgresCluster CRD
app.kubernetes.io/version: 5.3.0
bases:
- ../crd
- ../rbac/cluster
- ../manager
images:
- name: postgres-operator
newName: imwl/postgres-operator
newTag: ubi8-5.3.0-0
- name: postgres-operator-upgrade
newName: imwl/postgres-operator-upgrade
newTag: ubi8-5.3.0-0
patchesJson6902:
- target: { group: apps, version: v1, kind: Deployment, name: pgo }
path: selectors.yaml
- target: { group: apps, version: v1, kind: Deployment, name: pgo-upgrade }
path: selectors.yaml
安装 pg-cluster 高可用
主要修改的文件,按需修改。存储使用 rook-ceph 搭建的 rook-ceph-block-retain
kubectl apply -k kustomize/high-availability
1 | apiVersion: postgres-operator.crunchydata.com/v1beta1 |
因为 超级用户 不能访问 pgbouncer
pgbouncer-users-configmap.yaml
1 | apiVersion: v1 |
手动主备切换,当允许时1
2
3kubectl annotate -n postgres-operator postgrescluster hippo imwl postgres-operator.crunchydata.com/trigger-switchover="$(date)"
kubectl annotate -n postgres-operator postgrescluster hippo imwl postgres-operator.crunchydata.com/trigger-switchover="$(date)" --overwrite
创建完后,修改账号密码 集群名-pguser-用户名,测试全部密码 password
1 | kubectl patch secret -n postgres-operator imwl-pguser-hive -p '{"stringData":{"password":"password","verifier":""}}' |
数据库连接方式
- ssh 中转后 imwl-ha.postgres-operator.svc.cluster.local:5432 imwl/password
- ip:31432
更多信息参考官网和github