Using block storage volumes with services

Snowflake supports these storage volume types for your containerized applications: Snowflake internal stage, local storage, memory storage volumes, and block storage volumes.

Specifying block storage in service specification

To create a service that uses block storage, you provide the necessary configuration in the service specification as follows:

  1. Specify the spec.volumes field to define the block storage volumes to create.

    volumes:
      - name: <name>
        source: block
        size: <size in Gi>
        blockConfig:                             # optional
          initialContents:
            fromSnapshot: <snapshot name>
    
    Copy

    The following fields are required:

    • name: Name of the volume.

    • source: Type of the volume. For block storage volume, the value is block.

    • size: Storage capacity of the block storage volume measured in bytes. The value must always be an integer, specified using the Gi unit suffix. For example, 5Gi means 5*1024*1024*1024 bytes. The size value can range from 1Gi to 16384Gi.

    The following are optional fields that you can specify if you want to initialize the block volume using a previously taken snapshot (explained in the following sections) of another volume:

    • blockConfig: Add this field only if you want to use a snapshot to initialize the volume. The snapshot name can be a fully qualified SQL identifier, such as TUTORIAL_DB.DATA_SCHEMA.MY_SNAPSHOT. The snapshot name is resolved relative to the database and the schema of the service. That is, if you created your service in TUTORIAL_DB.DATA_SCHEMA, then fromSnapshot: MY_SNAPSHOT is equivalent to fromSnapshot: TUTORIAL_DB.DATA_SCHEMA.MY_SNAPSHOT.

  2. Specify the spec.containers.volumeMount field to describe where in your application containers to mount the block storage volumes. The information you provide in this field is the same for all supported storage volumes.

Access control requirements

If you want to use an existing snapshot (fromSnapshot is specified in the specification) to initialize the volume, the service owner role must have the USAGE privilege on the snapshot.

The service owner role must also have the USAGE privilege on the database and schema that contain the snapshot.

Guidelines and limitations

The following restrictions apply on services that use block storage volumes:

  • The service must have the same minimum and maximum number of instances.

  • After the service is created, the following apply:

    • You can’t change the number of service instances using the ALTER SERVICE … SET … command.

    • You can’t change the size of the block storage volume.

    • No new block storage volumes can be added, and no existing block storage volumes can be removed.

    • Block storage volumes are preserved if a service is upgraded, or suspended and resumed. When a service is suspended, the you continues to pay for the volume because it is preserved. After you upgrade or resume a service, Snowflake attaches each block storage volume to the same service instance ID as before.

    • Block storage volumes are deleted if service is dropped. To preserve data in the volumes, take snapshots of the volumes. You can use the snapshots later to initialize new volumes.

    • Block storage volumes do not support Tri-Secret Secure and Periodic rekeying. This means that if your account has enabled Tri-Secret Secure or periodic rekeying, while all other Snowflake data will continue to have added security, any images stored in your Snowpark Container Services block storage volumes will not benefit from this added security.

      To create a block storage volume in an account with Tri-Secret Secure or periodic rekeying, you must first confirm that you understand and agree to continue without the benefit from this additional security for your block storage volumes. To confirm agreement, an account administrator (user with the ACCOUNTADMIN role) will need to set the account-level parameter ENABLE_TRI_SECRET_AND_REKEY_OPT_OUT_FOR_SPCS_BLOCK_STORAGE to TRUE.

Managing snapshots

You can take snapshots of your block storage volume and later use the backup as follows:

  • Use the snapshot backup to restore an existing block storage volume.

  • Use the snapshot backup as seed data to initialize a new block storage volume when creating a new service.

You should ensure all your updates are flushed to the disk before you take the snapshot.

Snowflake provides the following commands to create and manage snapshots:

In addition, to restore a snapshot on an existing block storage volume, you can execute the ALTER SERVICE … RESTORE VOLUME command. Note that you need to suspend the service before you can restore a snapshot. After restoring a volume, service is automatically resumed.

Block storage costs

For more information, see Consumption Table.

Example

For an example, see Tutorial. The tutorial provides step-by-step instructions to create a service with a block storage volume mounted.