Skip to content

Operator config rootCA should be configurable via secret #1925

@Laraakaa

Description

@Laraakaa

In my current understanding, to get the Operator to work with strict TLS verification, one needs to do the following:

  1. Have a valid certificate issued with a CA, key and a certificate.
  2. Add the file openssl.xml to the "files" configuration in the CHI (provided below)
<clickhouse>
  <openSSL>
    <server>
      <certificateFile>/etc/clickhouse-server/certs/tls.crt</certificateFile>
      <privateKeyFile>/etc/clickhouse-server/certs/tls.key</privateKeyFile>
      <verificationMode>strict</verificationMode>
      <caConfig>/etc/clickhouse-server/certs/ca.crt</caConfig>
      <loadDefaultCAFile>true</loadDefaultCAFile>
      <cacheSessions>true</cacheSessions>
      <disableProtocols>sslv2,sslv3</disableProtocols>
      <preferServerCiphers>true</preferServerCiphers>
    </server>
    <client>
      <loadDefaultCAFile>true</loadDefaultCAFile>
      <cacheSessions>true</cacheSessions>
      <disableProtocols>sslv2,sslv3</disableProtocols>
      <preferServerCiphers>true</preferServerCiphers>
      <verificationMode>strict</verificationMode>
      <caConfig>/etc/clickhouse-server/certs/ca.crt</caConfig>
    </client>
  </openSSL>
</clickhouse>

Those certs can be mounted by a secret using the podTemplate or by specifying it like described here: https://altinity.com/blog/clickhouse-confidential-using-kubernetes-secrets-with-the-altinity-operator "Using Secrets to transmit X509 certificates and private keys".

  1. Add the rootCA in the operator config.yaml at clickhouse.access.rootCA, in my understanding to verify the certificate provided by the server against the CA. The issue is that this clickhouse.access.rootCA seems to only accept a certificate as string, and in our case it's generated by cert-manager. So we would have to either copy paste the generated certificates into the config.yaml as a string - which is not nice as it might expire and this would force us to do this manual thing again.
    For reference, it works when I don't set it at all but then I suppose it's not being verified.

A possible solution could be to add a property access.rootCAFile or similar, that would instead look for a certificate file on the disk. That would allow us to mount the dynamically generated CA as a secret.

Specifically I've looked at this part of the code: https://github.com/Altinity/clickhouse-operator/blob/master/pkg/model/clickhouse/connection.go#L124

And this old issue: #1073, which doesn't seem to fully answer the access.rootCA property in the operator config.yaml, and rather focuses on how to mount certificates in a CHI rather than for the operator itself.

I'm happy to provide a MR contribution if the issue is acknowledged 👍

Environment:
Chart 0.25.6
Kubernetes 1.33.7 (EKS)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions