美文网首页operator
PostgreSQL 学习笔记(3):高可用 Kubernete

PostgreSQL 学习笔记(3):高可用 Kubernete

作者: 香菜香菜我是折耳根 | 来源:发表于2020-09-04 16:41 被阅读0次

前言:Kubernetes 部署服务如果不熟悉的情况尽量使用 Helm 或者 Operator 。

https://github.com/zalando/postgres-operator

# First, clone the repository and change to the directory
git clone https://github.com/zalando/postgres-operator.git
cd postgres-operator

# apply the manifests in the following order
kubectl create -f manifests/configmap.yaml  # configuration
kubectl create -f manifests/operator-service-account-rbac.yaml  # identity and permissions
kubectl create -f manifests/postgres-operator.yaml  # deployment
kubectl create -f manifests/api-service.yaml  # operator API to be used by UI
# if you've created the operator using yaml manifests
kubectl get pod -l name=postgres-operator

# if you've created the operator using helm chart
kubectl get pod -l app.kubernetes.io/name=postgres-operator
# manual deployment
kubectl apply -f ui/manifests/
# create a Postgres cluster
kubectl create -f manifests/minimal-postgres-manifest.yaml
# check the deployed cluster
kubectl get postgresql

# check created database pods
kubectl get pods -l application=spilo -L spilo-role

# check created service resources
kubectl get svc -l application=spilo -L spilo-role

测试

export PGPASSWORD=$(kubectl get secret postgres.acid-minimal-cluster.credentials -o 'jsonpath={.data.password}' | base64 -d)
# Mac 用户使用 -D
# export PGPASSWORD=$(kubectl get secret postgres.acid-minimal-cluster.credentials -o 'jsonpath={.data.password}' | base64 -D)
kubectl exec -it acid-minimal-cluster-0 sh
export PGPASSWORD=dtP3mIHOmrztiLoWrqlYXqwLEX9ctFzmLWSZwLbB90LFW2kl9jFzmEoD6myY9ObJ
psql -h acid-minimal-cluster -p 5432 -U postgres

注:这里我是在 pod 容器里连接的,因为在 Mac 宿主机上连接时会报 SSL 连接异常。

相关文章

网友评论

    本文标题:PostgreSQL 学习笔记(3):高可用 Kubernete

    本文链接:https://www.haomeiwen.com/subject/wtzzsktx.html