Postgresql Zalando postgres操作员从k8s外部访问群集
我已安装postgres群集Zalando postgres操作员 如何从外部访问postgres数据库?Postgresql Zalando postgres操作员从k8s外部访问群集,postgresql,kubernetes,Postgresql,Kubernetes,我已安装postgres群集Zalando postgres操作员 如何从外部访问postgres数据库? 我试图将群集服务类型从ClusterIP更改为NodePort,但它会自动被覆盖。此处解释了此过程: 你需要两个步骤 打开并将端口转发到本地计算机的脚本 我创建了一个名为set\u dbforwarding.sh的脚本。你需要 将脚本中的名称更改为群集名称和设置! 所以cdf集群应该变成yourclustername #!/usr/bin/env bash se
我试图将群集服务类型从ClusterIP更改为NodePort,但它会自动被覆盖。此处解释了此过程: 你需要两个步骤
set\u dbforwarding.sh
的脚本。你需要
将脚本中的名称更改为群集名称和设置!
所以cdf集群
应该变成yourclustername
#!/usr/bin/env bash
set -u # crash on missing env variables
set -e # stop on any error
set -x # print what we are doing
export NAMESPACE=$1
export PGMASTER=$(kubectl -n cdf-acc get pods -o jsonpath={.items..metadata.name} -l application=spilo,cluster-name=cdf-cluster,spilo-role=m
# PGMASTER should be now the master node. There are cases under failover
# that you should connect to a different node in your cluster.
# If you want to change something you should always connect to the master.
# otherwise you get
# set up port forward
kubectl -n $NAMESPACE port-forward $PGMASTER 6432:5432
# get the password..it is printend in your terminal
# so you can use it in your db tool of choice.
export PGPASSWORD=$(kubectl -n $NAMESPACE get secret cdf.cdf-cluster.credentials.postgresql.acid.zalan.do -o 'jsonpath={.data.password}' | b
export PGSSLMODE=require
执行方式如下:
./set_dbforwarding.sh yourclusternamespace
#!/usr/bin/env bash
set -u # crash on missing env variables
set -e # stop on any error
set -x # print what we are doing
export NAMESPACE=$1
export DATABASE=$2
export DATABASEDUMP=$3
export PGMASTER=$(kubectl -n $NAMESPACE get pods -o jsonpath={.items..metadata.name} -l application=spilo,cluster-name=cdf-cluster,spilo-rol
export PGPASSWORD=$(kubectl -n $NAMESPACE get secret postgres.cdf-cluster.credentials.postgresql.acid.zalan.do -o 'jsonpath={.data.password}
export PGSSLMODE=require
# examples you can run now the the above ENV variables set.
# psql -h 127.0.0.1 -U postgres -d cdf -p 6432
#cat ~/dumps/cbs_schema_wfs.sql | psql -h 127.0.0.1 -U postgres -d cdf -p 6432
# pg_restore -h 127.0.0.1 -U postgres -p 6432 -d $2 -c $3
# data only
# pg_restore -h 127.0.0.1 -U postgres -p 6432 -d $2 -a $3
# everything
pg_restore -h 127.0.0.1 -U postgres -p 6432 -d $2 $3
./restore_db.sh namespace databasename backup.gz
这里解释了该过程: 你需要两个步骤
set\u dbforwarding.sh
的脚本。你需要
将脚本中的名称更改为群集名称和设置!
所以cdf集群
应该变成yourclustername
#!/usr/bin/env bash
set -u # crash on missing env variables
set -e # stop on any error
set -x # print what we are doing
export NAMESPACE=$1
export PGMASTER=$(kubectl -n cdf-acc get pods -o jsonpath={.items..metadata.name} -l application=spilo,cluster-name=cdf-cluster,spilo-role=m
# PGMASTER should be now the master node. There are cases under failover
# that you should connect to a different node in your cluster.
# If you want to change something you should always connect to the master.
# otherwise you get
# set up port forward
kubectl -n $NAMESPACE port-forward $PGMASTER 6432:5432
# get the password..it is printend in your terminal
# so you can use it in your db tool of choice.
export PGPASSWORD=$(kubectl -n $NAMESPACE get secret cdf.cdf-cluster.credentials.postgresql.acid.zalan.do -o 'jsonpath={.data.password}' | b
export PGSSLMODE=require
执行方式如下:
./set_dbforwarding.sh yourclusternamespace
#!/usr/bin/env bash
set -u # crash on missing env variables
set -e # stop on any error
set -x # print what we are doing
export NAMESPACE=$1
export DATABASE=$2
export DATABASEDUMP=$3
export PGMASTER=$(kubectl -n $NAMESPACE get pods -o jsonpath={.items..metadata.name} -l application=spilo,cluster-name=cdf-cluster,spilo-rol
export PGPASSWORD=$(kubectl -n $NAMESPACE get secret postgres.cdf-cluster.credentials.postgresql.acid.zalan.do -o 'jsonpath={.data.password}
export PGSSLMODE=require
# examples you can run now the the above ENV variables set.
# psql -h 127.0.0.1 -U postgres -d cdf -p 6432
#cat ~/dumps/cbs_schema_wfs.sql | psql -h 127.0.0.1 -U postgres -d cdf -p 6432
# pg_restore -h 127.0.0.1 -U postgres -p 6432 -d $2 -c $3
# data only
# pg_restore -h 127.0.0.1 -U postgres -p 6432 -d $2 -a $3
# everything
pg_restore -h 127.0.0.1 -U postgres -p 6432 -d $2 $3
./restore_db.sh namespace databasename backup.gz