Create shared storage service for Python
Zerops provides shared storage service that can be connected to runtime services. Shared storage enables your Python service to share files between all containers of the same service or even among containers of different runtime services.
Connect shared storage in Zerops GUI​
When creating new shared storage​
Connect your Python service directly when creating a new shared storage service. Select your Python service in the Share with Services block on the Add new shared storage service page.
Connect existing shared storage​
To connect existing shared storage to your Python service:
- Go to the shared storage service detail page
- Select Shared storage connections
- Choose your Python service from the list of runtime services
- The shared storage will be connected to your service
How it works​
Zerops creates a new folder /mnt/[shared storage name]
in your Python service's root directory. For example, /mnt/teststorage
for a teststorage
shared storage.
The content of this folder is shared among:
- All containers of your Python service
- All containers of other connected runtime services (if you connect multiple services)
Disconnect shared storage​
To disconnect shared storage from your Python service:
- Go to the shared storage service detail page
- Select Shared storage connections
- Switch off the toggle next to your Python service
Create Python service with shared storage using zCLI​
zCLI is the Zerops command-line tool. To create a new Python service with shared storage via command-line:
Create project description file​
Zerops uses YAML format to describe project infrastructure. Read the basics about defining Python services in description.yaml
.
Example with shared storage​
Create a directory my-project
and add a description.yaml
file:
# Basic project data
project:
name: my-project
description: A project with Python and shared storage
tags:
- DEMO
- ZEROPS
# Project services
services:
- # Shared storage service
hostname: teststorage
type: shared-storage
mode: NON_HA
- # Python service
hostname: app
type: python@3.12
minContainers: 1
maxContainers: 3
# Mount the shared storage
mount:
- teststorage
The mount
attribute accepts an array of shared storage names to mount to your Python service.
Create project with shared storage​
Follow the guide how to create a project based on description.yaml to deploy your Python service with shared storage.