Access multi-writer storage

Google Distributed Cloud (GDC) air-gapped provides file and block persistent storage for virtual machine (VM) and container workloads in your air-gapped sovereign environment.

GDC uses Kubernetes, which provides persistent block and file storage through PersistentVolumeClaim objects. A PersistentVolumeClaim (PVC) is a request for storage which is referenced by a Pod object. A pod is a group of one or more containers, with shared storage and network resources. A PersistentVolumeClaim object has an independent lifecycle from the pod which allows it to persist beyond a single pod.

Persistent storage is dynamically provisioned, so that the underlying volumes are created on-demand. In GDC, dynamic provisioning is provided by the following pre-installed StorageClass objects:

  • standard-rwo: ReadWriteOnce block storage class. The volume can only be accessed by one node at a time. This is the default.
  • standard-rwx: ReadWriteMany file storage. The volume can be accessed simultaneously by multiple nodes.

See Create stateful workloads for an example of how to deploy a stateful application with storage.

Before you begin

To run commands against a user cluster, ensure you have the following resources:

  1. Locate the user cluster name, or ask your Platform Administrator what the cluster name is.

  2. Sign in and generate the kubeconfig file for the user cluster if you don't have one.

  3. Use the kubeconfig path of the user cluster to replace USER_CLUSTER_KUBECONFIG in these instructions.

To get the required permissions to create a multi-writer volume, ask your Organization IAM Admin to grant you the Namespace Admin role.

Create a multi-writer volume

The GDC standard-rwx StorageClass provides multi-writer storage shared simultaneously by multiple Pod objects. The following instructions show how to create a multi-writer volume.

  1. Create a PersistentVolumeClaim and configure it with a ReadWriteMany access mode and a standard-rwx storage class:

    kubectl --kubeconfig USER_CLUSTER_KUBECONFIG \
        --namespace NAMESPACE apply -f - <<EOF
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: PVC_NAME
    spec:
      accessModes:
        - ReadWriteMany
      resources:
        requests:
          storage: 10Gi
    EOF
    

    Replace the following:

    • USER_CLUSTER_KUBECONFIG: the kubeconfig file for the user cluster.

    • NAMESPACE: the namespace in which to create the PVC.

    • PVC_NAME: the name of the PersistentVolumeClaim object.

  2. Configure your container workloads to use the multi-writer volume. The following is an example deployment of nginx that uses a multi-writer volume:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: web-server-deployment
      labels:
        app: nginx
    spec:
      replicas: 3
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: nginx
            volumeMounts:
            - mountPath: /usr/share/nginx/html
              name: data
          volumes:
          - name: data
            persistentVolumeClaim:
              claimName: PVC_NAME
    

    Replace PVC_NAME with the PVC you created.

Expand volume capacity

To increase the capacity of a PersistentVolumeClaim object, update the spec.resources.storage field to your desired capacity. The maximum supported volume size is 14.5 Ti.

Update the volume to a larger size in the manifest file of the PersistentVolumeClaim object:

kubectl --kubeconfig USER_CLUSTER_KUBECONFIG \
    --namespace NAMESPACE apply -f - <<EOF
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: PVC_NAME
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: VOLUME_STORAGE_SIZE
EOF

Replace the following:

  • USER_CLUSTER_KUBECONFIG: the kubeconfig file for the user cluster.

  • NAMESPACE: the namespace in which the PVC resource exists.

  • PVC_NAME: the name of the PVC for which you are increasing the storage size.

  • VOLUME_SNAPSHOT_SIZE: the storage size amount to increase, such as 50Gi.