Merge pull request #10104 from rook/mergify/bp/release-1.9/pr-9940

csi: add CSI encryption support (backport #9940)
This commit is contained in:
mergify[bot] authored and GitHub committed 2022-04-19 20:28:55 +00:00
commit be2fb09893
10 files changed
+119

No files matched your search

+71
View File
@@ -176,3 +176,74 @@ CSI-Addons supports the following operations:
- [Annotating PersistentVolumeClaims](https://github.com/csi-addons/kubernetes-csi-addons/blob/v0.3.0/docs/reclaimspace.md#annotating-perstentvolumeclaims)
- Network Fencing
- [Creating a NetworkFence](https://github.com/csi-addons/kubernetes-csi-addons/blob/v0.3.0/docs/networkfence.md)
## Enable RBD Encryption Support
Ceph-CSI supports encrypting individual RBD PersistentVolumeClaim with LUKS encryption. More details can be found
[here](https://github.com/ceph/ceph-csi/blob/v3.6.0/docs/deploy-rbd.md#encryption-for-rbd-volumes)
with full list of supported encryption configurations. A sample configmap can be found
[here](https://github.com/ceph/ceph-csi/blob/v3.6.0/examples/kms/vault/kms-config.yaml).
> NOTE: Rook also supports OSD encryption (see `encryptedDevice` option [here](ceph-cluster-crd.md#osd-configuration-settings)).
Using both RBD PVC encryption and OSD encryption together will lead to double encryption and may reduce read/write performance.
Unlike OSD encryption, existing ceph clusters can also enable Ceph-CSI RBD PVC encryption support and multiple kinds of encryption
KMS can be used on the same ceph cluster using different storageclasses.
Following steps demonstrate how to enable support for encryption:
* Create the `rook-ceph-csi-kms-config` configmap with required encryption configuration in
the same namespace where the Rook operator is deployed. An example is shown below:
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: rook-ceph-csi-kms-config
namespace: rook-ceph
data:
config.json: |-
{
"user-secret-metadata": {
"encryptionKMSType": "metadata",
"secretName": "storage-encryption-secret"
}
}
```
* Update the `rook-ceph-operator-config` configmap and patch the
following configurations
```bash
kubectl patch cm rook-ceph-operator-config -nrook-ceph -p $'data:\n "CSI_ENABLE_ENCRYPTION": "true"'
```
* Create necessary resources (secrets, configmaps etc) as required by the encryption type.
In this case, create `storage-encryption-secret` secret in the namespace of pvc as shown:
```yaml
apiVersion: v1
kind: Secret
metadata:
name: storage-encryption-secret
namespace: rook-ceph
stringData:
encryptionPassphrase: test-encryption
```
* Create a new [storageclass](../deploy/examples/csi/rbd/storageclass.yaml) with additional parameters
`encrypted: "true"` and `encryptionKMSID: "<key used in configmap>"`. An example is show below:
```yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: rook-ceph-block-encrypted
parameters:
# additional parameters required for encryption
encrypted: "true"
encryptionKMSID: "user-secret-metadata"
# ...
```
* PVCs created using the new storageclass will be encrypted.
+1
View File
@@ -84,6 +84,7 @@ The following tables lists the configurable parameters of the rook-operator char
| `csi.enableGrpcMetrics` | Enable Ceph CSI GRPC Metrics. | `false` |
| `csi.enableCSIHostNetwork` | Enable Host Networking for Ceph CSI nodeplugins. | `false` |
| `csi.enablePluginSelinuxHostMount` | Enable Host mount for /etc/selinux directory for Ceph CSI nodeplugins. | `false` |
| `csi.enableCSIEncryption` | Enable Ceph CSI PVC encryption support. | `false` |
| `csi.provisionerTolerations` | Array of tolerations in YAML format which will be added to CSI provisioner deployment. | <none> |
| `csi.provisionerNodeAffinity` | The node labels for affinity of the CSI provisioner deployment (***) | <none> |
| `csi.pluginTolerations` | Array of tolerations in YAML format which will be added to CephCSI plugin DaemonSet | <none> |
@@ -14,6 +14,7 @@ data:
CSI_ENABLE_CEPHFS_SNAPSHOTTER: {{ .Values.csi.enableCephfsSnapshotter | quote }}
CSI_ENABLE_RBD_SNAPSHOTTER: {{ .Values.csi.enableRBDSnapshotter | quote }}
CSI_PLUGIN_ENABLE_SELINUX_HOST_MOUNT: {{ .Values.csi.enablePluginSelinuxHostMount | quote }}
CSI_ENABLE_ENCRYPTION: {{ .Values.csi.enableCSIEncryption | quote }}
CSI_ENABLE_OMAP_GENERATOR: {{ .Values.csi.enableOMAPGenerator | quote }}
{{- if .Values.csi.pluginPriorityClassName }}
CSI_PLUGIN_PRIORITY_CLASSNAME: {{ .Values.csi.pluginPriorityClassName | quote }}
+2
View File
@@ -70,6 +70,8 @@ csi:
enableRBDSnapshotter: true
# set to false if the selinux is not enabled or unavailable in cluster nodes.
enablePluginSelinuxHostMount : false
# set to true to enable Ceph CSI pvc encryption support.
enableCSIEncryption: false
# (Optional) set user created priorityclassName for csi plugin pods.
# pluginPriorityClassName: system-node-critical
@@ -47,6 +47,15 @@ parameters:
# https://docs.ceph.com/docs/master/man/8/rbd-nbd/#options
# unmapOptions: force
# (optional) Set it to true to encrypt each volume with encryption keys
# from a key management system (KMS)
# encrypted: "true"
# (optional) Use external key management system (KMS) for encryption key by
# specifying a unique ID matching a KMS ConfigMap. The ID is only used for
# correlation to configmap entry.
# encryptionKMSID: <kms-config-id>
# RBD image format. Defaults to "2".
imageFormat: "2"
+3
View File
@@ -119,6 +119,9 @@ data:
ROOK_CSI_ENABLE_NFS: "false"
ROOK_CSI_ENABLE_GRPC_METRICS: "false"
# Set to true to enable Ceph CSI pvc encryption support.
CSI_ENABLE_ENCRYPTION: "false"
# Set to true to enable host networking for CSI CephFS and RBD nodeplugins. This may be necessary
# in some network configurations where the SDN does not provide access to an external cluster or
# there is significant drop in read/write performance.
+3
View File
@@ -34,6 +34,9 @@ data:
ROOK_CSI_ENABLE_NFS: "false"
ROOK_CSI_ENABLE_GRPC_METRICS: "false"
# Set to true to enable Ceph CSI pvc encryption support.
CSI_ENABLE_ENCRYPTION: "false"
# Set to true to enable host networking for CSI CephFS and RBD nodeplugins. This may be necessary
# in some network configurations where the SDN does not provide access to an external cluster or
# there is significant drop in read/write performance.
+5
View File
@@ -64,6 +64,7 @@ type Param struct {
EnableCSIAddonsSideCar bool
MountCustomCephConf bool
EnableOIDCTokenProjection bool
EnableCSIEncryption bool
LogLevel uint8
CephFSGRPCMetricsPort uint16
CephFSLivenessMetricsPort uint16
@@ -366,6 +367,10 @@ func (r *ReconcileCSI) startDrivers(ver *version.Info, ownerInfo *k8sutil.OwnerI
tp.EnableCSIAddonsSideCar = true
}
if strings.EqualFold(k8sutil.GetValue(r.opConfig.Parameters, "CSI_ENABLE_ENCRYPTION", "false"), "true") {
tp.EnableCSIEncryption = true
}
if strings.EqualFold(k8sutil.GetValue(r.opConfig.Parameters, "CSI_CEPHFS_PLUGIN_UPDATE_STRATEGY", rollingUpdate), onDelete) {
tp.CephFSPluginUpdateStrategy = onDelete
} else {
@@ -230,6 +230,10 @@ spec:
mountPath: /run/secrets/tokens
readOnly: true
{{ end }}
{{ if .EnableCSIEncryption }}
- name: rook-ceph-csi-kms-config
mountPath: /etc/ceph-csi-encryption-kms-config/
{{ end }}
- name: liveness-prometheus
image: {{ .CSIPluginImage }}
args:
@@ -300,3 +304,11 @@ spec:
expirationSeconds: 3600
audience: ceph-csi-kms
{{ end }}
{{ if .EnableCSIEncryption }}
- name: rook-ceph-csi-kms-config
configMap:
name: rook-ceph-csi-kms-config
items:
- key: config.json
path: config.json
{{ end }}
@@ -128,6 +128,10 @@ spec:
mountPath: /run/secrets/tokens
readOnly: true
{{ end }}
{{ if .EnableCSIEncryption }}
- name: rook-ceph-csi-kms-config
mountPath: /etc/ceph-csi-encryption-kms-config/
{{ end }}
{{ if .EnableCSIAddonsSideCar }}
- name: csi-addons
securityContext:
@@ -265,3 +269,11 @@ spec:
expirationSeconds: 3600
audience: ceph-csi-kms
{{ end }}
{{ if .EnableCSIEncryption }}
- name: rook-ceph-csi-kms-config
configMap:
name: rook-ceph-csi-kms-config
items:
- key: config.json
path: config.json
{{ end }}