0

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

这里有什么帮助吗?

4

1 回答 1

3

我已经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

你也可以参考这篇文章,希望对你有帮助。

于 2019-10-28T13:31:24.230 回答