注意
若Kubernetes集群中部署了多套HBlock CSI,需在各自对应的安装路径下,配置加密模式。
对于配置文件中的一些敏感信息,可以采用加密模式进行配置。当使用的卷在HBlock中配置了质询握手认证协议(Challenge-Handshake Authentication Protocol,CHAP),则需要配置CHAP认证的用户名和密码。为了确保数据安全,建议采用加密模式来配置CHAP密码。
在使用CHAP方式时,输入的chapUser和chapPassword为加密字符串。加密字符串可以使用下列方法生成:使用deploy/csi-plugin-conf/csi-secret-decrypt.yaml中的DecryptData配置的密钥对原来的字符串进行AES(ECP、paddingcs7)加密,加密后的结果进行base64编码。
配置步骤
配置加密密钥。
修改deploy/csi-plugin-conf/csi-secret-decrypt.yaml配置文件中的decryptFlag和decryptData参数。
apiVersion: v1 kind: Secret metadata: name: csi-plugin-stor-secret-decrypt namespace: @DRIVER_NAMESPACE@ type: Opaque data: #是否启用加密,配置为true(启用)或false(不启用)的base64编码字符串 decryptFlag: decryptFlag #密钥的base64编码字符串,密钥长度必须为16位 decryptData: decryptData #密钥的base64编码
参数
参数 描述 是否必填 metadata.name Secret资源的资源名称。
取值csi-plugin-stor-secret-decrypt,不可更改。
是 metadata.namespace 绑定的Kubernetes命名空间。
取值:
如果已经安装 HBlock CSI:命名空间已确定,直接将该字段值修改为对应命名空间值,保持完成csi-configMap.yaml文件的修改、保存并应用后,相关配置即可自动生效。
如果还未安装HBlock CSI:此字段取值保持为@DRIVER_NAMESPACE@,执行deploy安装脚本时,即可自动替换为对应的命名空间。
是 decryptFlag 是否启用加密模式,配置为true(启用)或false(不启用)的Base64编码字符串。
取值:
- dHJ1ZQ==:启用加密,true的Base64编码。
- ZmFsc2U=:不启用加密,false的Base64编码。
默认不启用加密。
否 decryptData 加密的密钥。
说明
启用加密,此参数必填。
取值:源码为16位的字符串。需要对源码进行Base64编码。
条件 示例:
启用加密模式。例如decryptFlag的源码为true,decryptData的源码为stor012345678901。
使用Base64工具对decryptFlag、decryptData的源码进行编码。
对decryptFlag源码进行Base64编码,编码后的decryptFlag如下:
dHJ1ZQ==
对decryptData源码进行Base64编码,编码后的decryptData如下:
c3RvcjAxMjM0NTY3ODkwMQ==
修改配置文件deploy/csi-plugin-conf/csi-secret-decrypt.yaml配置文件中的参数。
apiVersion: v1 kind: Secret metadata: name: csi-plugin-stor-secret-decrypt namespace: defualt type: Opaque data: decryptFlag: dHJ1ZQ== decryptData: c3RvcjAxMjM0NTY3ODkwMQ==
应用配置文件csi-secret-decrypt.yaml。
[root@server csi-plugin-conf]# kubectl apply -f csi-secret-decrypt.yaml secret/csi-plugin-stor-secret-decrypt configured
加密配置项。
以静态PV中PV YAML配置文件(csi-pv-local.yaml)为例,加密CHAP认证的密码,采用AES 128位加密,填充PKCS7的Padding加密CHAP密码,并对加密后的结果进行Base64编码。
apiVersion: v1 kind: PersistentVolume metadata: name: csi-pv-test labels: app: stor-pv-test spec: capacity: storage: 1Gi volumeMode: Filesystem #卷模式,支持Filesystem和Block模式,默认为Filesystem模式。 accessModes: # 访问模式 - ReadWriteOnce persistentVolumeReclaimPolicy: Retain csi: driver: stor.csi.k8s.io volumeHandle: stor:lun1 volumeAttributes: fsType: xfs readOnly: "false" #是否使用CHAP验证 chapEnable: "true" chapUser: username chapPassword: password
chapUser和chapPassword加密步骤:
使用AES加密工具。“工作模式”为“ECB”,“填充模式”为“PKCS7”,“密钥长度”为“AES-128”。
“加密密钥”使用DecryptData配置的密钥字符串(对应步骤1中的decryptData的源码,如步骤1举例中使用的源码为stor012345678901)。
输入加密文本(chapUser或chapPassword的源码),点击“开始AES加密文本”。下图中为chapUser=csi123的加密方式,chapPassword按下图方式加密即可。