【问题标题】:Zalando postgres operator issue with configZalando postgres 操作员配置问题
【发布时间】:2019-10-24 16:41:34
【问题描述】:

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

这里有什么帮助吗?

【问题讨论】:

    标签: postgresql kubernetes kubernetes-operator


    【解决方案1】:

    我已经在我的环境中设置了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,希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-13
      • 2020-06-19
      • 1970-01-01
      • 2011-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多