Zalando postgres 操作员配置问题

Zalando postgres operator issue with config

解决 Zalando Postgres 运算符的问题。默认清单应用于 Kubernetes 集群(本地托管),如下所示: https://github.com/zalando/postgres-operator/tree/4a099d698d641b80c5aeee5bee925921b7283489/manifests

已验证操作员名称或配置映射或服务帐户定义中是否存在任何问题,但无法弄清楚。

kubectl logs -f postgres-operator-944b9d484-9h796
2019/10/24 16:31:02 Spilo operator v1.2.0
2019/10/24 16:31:02 Fully qualified configmap name: default/postgres-operator
panic: configmaps "postgres-operator" is forbidden: User "system:serviceaccount:default:zalando-postgres-operator" cannot get resource "configmaps" in API group "" in the namespace "default"
goroutine 1 [running]:
github.com/zalando/postgres-operator/pkg/controller.(*Controller).initOperatorConfig(0xc0004a6000)
    /root/go/src/github.com/zalando/postgres-operator/pkg/controller/controller.go:102 +0x687
github.com/zalando/postgres-operator/pkg/controller.(*Controller).initController(0xc0004a6000)
    /root/go/src/github.com/zalando/postgres-operator/pkg/controller/controller.go:253 +0x825
github.com/zalando/postgres-operator/pkg/controller.(*Controller).Run(0xc0004a6000, 0xc000464660, 0xc000047a70)
    /root/go/src/github.com/zalando/postgres-operator/pkg/controller/controller.go:348 +0x2f
main.main()
    /workspace/cmd/main.go:82 +0x256

这里有什么帮助吗?

我已经在我的环境中设置了 postgres-operator,它在我的情况下运行良好。请确保您已按照以下步骤操作:

克隆 postgres-operator 回购:

$ git clone https://github.com/zalando/postgres-operator
$ cd postgres-operator

Zalando 的 Operator 可以通过两种方式配置——使用经典的 configmap,或者使用 CRD 配置对象,后者更强大:

$ kubectl create -f manifests/operator-service-account-rbac.yaml 
serviceaccount/zalando-postgres-operator created
clusterrole.rbac.authorization.k8s.io/zalando-postgres-operator created
clusterrolebinding.rbac.authorization.k8s.io/zalando-postgres-operator created

为了使用 CRD 配置,您必须更改 postgres-operator 本身的值。更改 manifests/postgres-operator.yaml 中的最后几行,使其显示为:

env:
# provided additional ENV vars can overwrite individual config map entries
#- name: CONFIG_MAP_NAME
#  value: "postgres-operator"
# In order to use the CRD OperatorConfiguration instead, uncomment these lines and comment out the two lines above
- name: POSTGRES_OPERATOR_CONFIGURATION_OBJECT
  value: postgresql-operator-default-configuration

该文件中给出的服务帐户名称与运营商服务帐户定义中给出的名称不匹配,因此您必须调整并创建引用的实际配置对象。这放在 manifests/postgresql-operator-default-configuration.yaml 中。这些是必须设置的值:

configuration:
  kubernetes:
    pod_environment_configmap: postgres-pod-config
    pod_service_account_name: zalando-postgres-operator

让我们创建运算符及其配置。

$ kubectl create -f manifests/postgres-operator.yaml 
deployment.apps/postgres-operator created

请等待几分钟,然后输入以下命令:

$ kubectl create -f postgresql-operator-default-configuration.yaml 
operatorconfiguration.acid.zalan.do/postgresql-operator-default-configuration created

现在,您将能够看到您的 POD 运行:

$ kubectl get pods
NAME                                 READY   STATUS    RESTARTS   AGE
postgres-operator-599fd68d95-c8z67   1/1     Running   0          21m

你也可以参考这篇article,希望对你有所帮助