Tutorial 5: Create a service with a block storage volume mounted¶
Introduction¶
This tutorial provides step-by-step instructions for you to create a simple service that uses a block storage volume. You also take a snapshot of the storage volume and explore ways to use the snapshot.
Create a service¶
-
Follow Tutorial 1 to download code for the sample service, create a Docker image, and upload it to a repository in your Snowflake account.
-
Verify you have the
my_echo_service_imageimage in the repository. -
Create a service. When the service runs, the container will have a 10 Gi block volume storage mounted.
Note
This tutorial only shows how to create a service with a block storage volume. The service code doesn’t use the volume.
-
To verify that the service is running, execute the DESCRIBE SERVICE command.
Verify the
statuscolumn shows the service status as RUNNING; if the status is PENDING, it indicates the service is still starting. To investigate why the service is not RUNNING, execute the SHOW SERVICE CONTAINERS IN SERVICE command and review thestatusof individual containers:
Take a snapshot¶
-
Use the CREATE SNAPSHOT command to take a snapshot of the block storage volume attached to the service instance 0. You specify instance 0 because you are running only one service instance.
Use double-quotes around the name in the VOLUME parameter to match the case of the name in the service specification.
-
Review the snapshot
-
List snapshots using SHOW SNAPSHOTS.
-
Retrieve information for a specific snapshot using DESCRIBE SNAPSHOT.
-
-
Run the ALTER SNAPSHOT command to modify the snapshot.
Use the snapshot¶
-
You can use the snapshot two ways:
-
Use snapshot to create a new service: When creating a new service, you can use the snapshot as the initial content for a block storage volume as shown. The following CREATE SERVICE command creates another service (
new_service) with a 50 Gi block storage volume. The inline specification includes the snapshot name to use for initializing the block storage volume. -
Restore a snapshot on a storage volume of an existing service: This example restarts the first service (
my_service) you created by replacing the original block volume content with the content from the snapshot.-
Suspend the service so you can restore the snapshot on the block storage volume.
-
Restore the snapshot on the block storage volume mounted on the container of the new_service instance. You are running only one instance of the Echo Service, so you specify instance ID 0.
-
Verify the service status.
The
statuscolumn should show the service status as RUNNING;
-
-
-
Use the DROP SNAPSHOT command to drop the snapshot.
Clean up¶
Remove the resources you created.
- Drop the two services you created:
- Follow Tutorial 1 steps to clean up other resources created in tutorial 1.
What’s next?¶
Now that you’ve completed this tutorial, you can return to Advanced tutorials to explore other topics.