constellation/docs/versioned_docs/version-2.10/workflows/storage.md
edgelessci dfe7c9884b
docs: add release v2.10.0 (#2220)
* docs: add release v2.10.0

* fix link

---------

Co-authored-by: elchead <elchead@users.noreply.github.com>
Co-authored-by: Thomas Tendyck <tt@edgeless.systems>
2023-08-16 15:07:03 +02:00

11 KiB

Use persistent storage

Persistent storage in Kubernetes requires cloud-specific configuration. For abstraction of container storage, Kubernetes offers volumes, allowing users to mount storage solutions directly into containers. The Container Storage Interface (CSI) is the standard interface for exposing arbitrary block and file storage systems into containers in Kubernetes. Cloud service providers (CSPs) offer their own CSI-based solutions for cloud storage.

Confidential storage

Most cloud storage solutions support encryption, such as GCE Persistent Disks (PD). Constellation supports the available CSI-based storage options for Kubernetes engines in AWS, Azure, and GCP. However, their encryption takes place in the storage backend and is managed by the CSP. Thus, using the default CSI drivers for these storage types means trusting the CSP with your persistent data.

To address this, Constellation provides CSI drivers for AWS EBS, Azure Disk, and GCE PD, offering encryption on the node level. They enable transparent encryption for persistent volumes without needing to trust the cloud backend. Plaintext data never leaves the confidential VM context, offering you confidential storage.

For more details see encrypted persistent storage.

CSI drivers

Constellation supports the following drivers, which offer node-level encryption and optional integrity protection.

Constellation CSI driver for Azure Disk: Mount Azure Disk Storage into your Constellation cluster. See the instructions on how to install the Constellation CSI driver or check out the repository for more information. Since Azure Disks are mounted as ReadWriteOnce, they're only available to a single pod.

Constellation CSI driver for GCP Persistent Disk: Mount Persistent Disk block storage into your Constellation cluster. Follow the instructions on how to install the Constellation CSI driver or check out the repository for more information.

Constellation CSI driver for AWS Elastic Block Store Mount Elastic Block Store storage volumes into your Constellation cluster. Follow the instructions on how to install the Constellation CSI driver or check out the repository for more information.

Note that in case the options above aren't a suitable solution for you, Constellation is compatible with all other CSI-based storage options. For example, you can use AWS EFS, Azure Files, or GCP Filestore with Constellation out of the box. Constellation is just not providing transparent encryption on the node level for these storage types yet.

Installation

The Constellation CLI automatically installs Constellation's CSI driver for the selected CSP in your cluster. If you don't need a CSI driver or wish to deploy your own, you can disable the automatic installation by setting deployCSIDriver to false in your Constellation config file.

Azure comes with two storage classes by default.

  • encrypted-rwo
    • Uses Standard SSDs
    • ext-4 filesystem
    • Encryption of all data written to disk
  • integrity-encrypted-rwo
    • Uses Premium SSDs
    • ext-4 filesystem
    • Encryption of all data written to disk
    • Integrity protection of data written to disk

For more information on encryption algorithms and key sizes, refer to cryptographic algorithms.

:::info

The default storage class is set to encrypted-rwo for performance reasons. If you want integrity-protected storage, set the storageClassName parameter of your persistent volume claim to integrity-encrypted-rwo.

Alternatively, you can create your own storage class with integrity protection enabled by adding csi.storage.k8s.io/fstype: ext4-integrity to the class parameters. Or use another filesystem by specifying another file system type with the suffix -integrity, e.g., csi.storage.k8s.io/fstype: xfs-integrity.

Note that volume expansion isn't supported for integrity-protected disks.

:::

GCP comes with two storage classes by default.

For more information on encryption algorithms and key sizes, refer to cryptographic algorithms.

:::info

The default storage class is set to encrypted-rwo for performance reasons. If you want integrity-protected storage, set the storageClassName parameter of your persistent volume claim to integrity-encrypted-rwo.

Alternatively, you can create your own storage class with integrity protection enabled by adding csi.storage.k8s.io/fstype: ext4-integrity to the class parameters. Or use another filesystem by specifying another file system type with the suffix -integrity, e.g., csi.storage.k8s.io/fstype: xfs-integrity.

Note that volume expansion isn't supported for integrity-protected disks.

:::

AWS comes with two storage classes by default.

  • encrypted-rwo
  • integrity-encrypted-rwo
    • Uses SSDs of gp3 type
    • ext-4 filesystem
    • Encryption of all data written to disk
    • Integrity protection of data written to disk

For more information on encryption algorithms and key sizes, refer to cryptographic algorithms.

:::info

The default storage class is set to encrypted-rwo for performance reasons. If you want integrity-protected storage, set the storageClassName parameter of your persistent volume claim to integrity-encrypted-rwo.

Alternatively, you can create your own storage class with integrity protection enabled by adding csi.storage.k8s.io/fstype: ext4-integrity to the class parameters. Or use another filesystem by specifying another file system type with the suffix -integrity, e.g., csi.storage.k8s.io/fstype: xfs-integrity.

Note that volume expansion isn't supported for integrity-protected disks.

:::

  1. Create a persistent volume

    A persistent volume claim is a request for storage with certain properties. It can refer to a storage class. The following creates a persistent volume claim, requesting 20 GB of storage via the encrypted-rwo storage class:

    cat <<EOF | kubectl apply -f -
    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
      name: pvc-example
      namespace: default
    spec:
      accessModes:
      - ReadWriteOnce
      storageClassName: encrypted-rwo
      resources:
        requests:
          storage: 20Gi
    EOF
    
  2. Create a Pod with persistent storage

    You can assign a persistent volume claim to an application in need of persistent storage. The mounted volume will persist restarts. The following creates a pod that uses the previously created persistent volume claim:

    cat <<EOF | kubectl apply -f -
    apiVersion: v1
    kind: Pod
    metadata:
      name: web-server
      namespace: default
    spec:
      containers:
      - name: web-server
        image: nginx
        volumeMounts:
        - mountPath: /var/lib/www/html
          name: mypvc
      volumes:
      - name: mypvc
        persistentVolumeClaim:
          claimName: pvc-example
          readOnly: false
    EOF
    

Change the default storage class

The default storage class is responsible for all persistent volume claims that don't explicitly request storageClassName. Constellation creates a storage class with encryption enabled and sets this as the default class. In case you wish to change it, follow the steps below:

  1. List the storage classes in your cluster:

    kubectl get storageclass
    

    The output is similar to this:

    NAME                      PROVISIONER                         RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
    encrypted-rwo (default)   {your-csp}.csi.confidential.cloud   Delete          Immediate           true                   1d
    integrity-encrypted-rwo   {your-csp}.csi.confidential.cloud   Delete          Immediate           false                  1d
    

    The default storage class is marked by (default).

  2. Mark old default storage class as non default

    If you previously used another storage class as the default, you will have to remove that annotation:

    kubectl patch storageclass encrypted-rwo -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'
    
  3. Mark new class as the default

    kubectl patch storageclass integrity-encrypted-rwo -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
    
  4. Verify that your chosen storage class is default:

    kubectl get storageclass
    

    The output is similar to this:

    NAME                                PROVISIONER                         RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
    encrypted-rwo                       {your-csp}.csi.confidential.cloud   Delete          Immediate           true                   1d
    integrity-encrypted-rwo (default)   {your-csp}.csi.confidential.cloud   Delete          Immediate           false                  1d