我可以在Kubernetes中将cloudql-proxy作为守护进程运行吗?

Edw*_*ung 7 google-cloud-sql google-kubernetes-engine

我有一个类似于这个github问题的问题.

但是,我可以使用守护进程而不是服务来代替使用服务吗?我们的想法是与同一节点上的所有pod共享同一个套接字.它是否会遇到与同一问题的答案中提到的相同的安全问题.我问,因为边车容器的方法阻止我产生更多的豆荚.实际上,我有不同类型的服务在Cloud SQL上使用相同的数据库.每个pod都必须为代理保留一些CPU和内存,这对我来说听起来多余.

Dou*_*oug 5

Yes you can do this. However, the pod for the daemonset will no longer listen on localhost. So you must configure both the cloud_sql_proxy and database connection to use the hostIP of the Node.

You must set your cloud_sql_proxy to listen on 0.0.0.0

  - command:
    - /cloud_sql_proxy
    - -instances=project:region:db=tcp:0.0.0.0:5432
    - -credential_file=/secrets/cloudsql/credentials.json
Run Code Online (Sandbox Code Playgroud)

You must also change your database connection to use the hostIP

    env:
    - name: DB_HOST
      valueFrom:
        fieldRef:
          apiVersion: v1
          fieldPath: status.hostIP
Run Code Online (Sandbox Code Playgroud)


Edw*_*ung 0

我在同一个 repo中问了同样的问题。团队的答案是肯定的。您可以使用守护进程设置方法。但是,我对守护进程集方法没有任何实践经验。因此请谨慎使用。