如何在 K8ssandra 中为 Cassandra 配置节点间加密(即 TLS)?
1 回答
K8ssandra 1.4.0 包含一些应该可以配置 TLS 的更改。作为参考,这是ticket,这是对应的PR。
有一个图表属性,cassandraYamlConfigMap
您可以使用它指定一个包含您的自定义的 ConfigMap cassandra.yaml
。您提供的属性将与 k8ssandra 生成的属性合并,您的优先。
请注意,您cassandra.yaml
不需要是完整的配置文件。仅指定您感兴趣的属性就足够了,因为它将与 K8ssandra 生成的基础配置文件合并。
节点间和客户端加密需要一些额外的属性,因为您需要指定密钥库和信任库机密,以便可以创建卷挂载。请注意,您需要提前创建密钥库和信任库机密。
在此处查看新图表属性的内联文档。
这是一个演示新属性的示例图表属性文件:
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
关于图表属性有几点需要注意。首先,keystoreSecret
引用truststoreSecret
应该存在于安装 k8ssandra 的同一命名空间中的秘密。用户应该在安装(或升级 k8ssandra)之前创建这些秘密。
其次,keystoreMountPath
指定truststoreMountPath
这些秘密应该安装在 Cassandra pod 中的哪个位置。必须指定这些属性,并且必须与 中指定的内容相匹配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。考虑到这一点,我推荐以下内容以供进一步阅读: