在 K8ssandra 中配置节点间加密(TLS)

Configuring internode encryption (TLS) in K8ssandra

如何在 K8ssandra 中为 Cassandra 配置节点间加密(即 TLS)?

K8ssandra 1.4.0 包含一些更改,应该可以配置 TLS。作为参考,这是 ticket, and this is the corresponding PR.

有图表 属性、cassandraYamlConfigMap,您可以使用它指定包含自定义 cassandra.yaml 的 ConfigMap。您提供的属性将与 k8ssandra 生成的属性合并,您的属性优先。

请注意,您的 cassandra.yaml 不需要是完整的配置文件。仅指定您感兴趣的属性就足够了,因为它将与 K8ssandra 生成的基础配置文件合并。

节点间和客户端加密需要一些额外的属性,因为您需要指定密钥库和信任库机密,以便可以创建卷装载。请注意,您需要提前创建密钥库和信任库机密。

查看新图表属性的内联文档 here

这是一个演示新属性的示例图表属性文件:

cassandra:
  version: 4.0.1
  cassandraYamlConfigMap: cassandra-config
  encryption:
    keystoreSecret: keystore
    keystoreMountPath: /mnt/keystore
    truststoreSecret: truststore
    truststoreMountPath: /mnt/truststore
  heap:
    size: 512M
  datacenters:
  - name: dc1
    size: 1

关于图表属性,有几点需要注意。首先,keystoreSecrettruststoreSecret 指的是应该位于安装了 k8ssandra 的同一个命名空间中的秘密。用户应该在安装(或升级 k8ssandra)之前创建这些秘密。

其次,keystoreMountPathtruststoreMountPath 指定在 Cassandra pods 中应安装这些机密的位置。必须指定这些属性,并且必须与 cassandra.yaml.

中指定的相匹配

这是一个包含我的自定义 cassandra.yaml:

的 ConfigMap 示例
apiVersion: v1
kind: ConfigMap
metadata:
  name: cassandra-config
data:
  cassandra.yaml: |-
    server_encryption_options:
      internode_encryption: all
      keystore: /mnt/keystore/keystore.jks
      keystore_password: cassandra
      truststore: /mnt/truststore/truststore.jks
      truststore_password: cassandra

K8ssandra 使用 Cass Operator 来管理 Cassandra。考虑到这一点,我建议进一步阅读以下内容:

  • 本文 article 涵盖了使用 cert-manager 为 cass-operator 管理的集群配置 TLS。
  • 这篇ticket详细解释了Cass Operator如何配置节点间加密。