Mounting an ephemeral disk to a container
Note
This feature is in the Preview stage. To get access, contact tech support
-
In the management console
, select the folder with your container. -
Select Serverless Containers.
-
Select the container.
-
In the left-hand menu, select
Editor. -
Under Mounted ephemeral disk:
-
Click Add ephemeral disk.
-
Specify the following in the field:
-
Mount path: Absolute mount path. Use this path to access the directory the disk will be mounted to.
Do not use this path for anything other than an empty directory; otherwise, the container initialization may result in an error, and the mounted ephemeral disk will become unavailable. To mount the ephemeral disk correctly, provide the full absolute path to the mount point.
-
Disk size: Amount of memory you want to allocate for the ephemeral disk you are mounting.
-
-
-
Click Create revision.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID>
command. You can also set a different folder for any specific command using the --folder-name
or --folder-id
parameter.
To mount an ephemeral disk to a container, run this command:
yc serverless container revision deploy \
--container-name=<container_name> \
--environment <runtime_environment> \
--image <container_image_path> \
--memory <RAM_size> \
--execution-timeout <execution_timeout> \
--service-account-id <service_account_ID> \
--mount type=ephemeral-disk,mount-point=<mount_point>,size=<disk_size>
Where:
--container-name
: Container name.--environment
: Runtime environment.--image
: Container image path.--memory
: Amount of RAM.--execution-timeout
: Maximum container execution time before timeout.--service-account-id
: Service account ID.--mount
: Ephemeral disk mounting parameters:type=ephemeral-disk
: Type of the file system being mounted.mount-point
: Absolute mount path. Use this path to access the directory the disk will be mounted to. Do not use this path for anything other than an empty directory; otherwise, the container initialization may result in an error, and the mounted ephemeral disk will become unavailable. To mount the ephemeral disk correctly, provide the full absolute path to the mount point.size
: Ephemeral disk size in GB, e.g.,size=5GB
.
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the relevant documentation on the Terraform
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
To mount an ephemeral disk to a container:
-
Open the Terraform configuration file and add the
mounts
section to the container description:resource "yandex_serverless_container" "ephemeral_storage_container" { name = "<container_name>" memory = "<RAM_size>" execution_timeout = "<execution_timeout>" service_account_id = "<service_account_ID>" content { zip_filename = "<path_to_ZIP_archive>" } image { url = <container_image_path> } mounts { mount_point_path = <mount_point> ephemeral_disk { size_gb = <disk_size> } } }
Where:
mounts
: Ephemeral disk mounting parameters:mount_point_path
: Absolute mount path. Use this path to access the directory the disk will be mounted to. Do not use this path for anything other than an empty directory; otherwise, the container initialization may result in an error, and the mounted ephemeral disk will become unavailable. To mount the ephemeral disk correctly, provide the full absolute path to the mount point.size_gb
: Ephemeral disk size in GB, e.g.,size=5GB
.
For more information about the
yandex_serverless_container
resource parameters, see this Terraform article . -
Apply the changes:
-
In the terminal, go to the directory where you edited the configuration file.
-
Make sure the configuration file is correct using this command:
terraform validate
If the configuration is correct, you will get this message:
Success! The configuration is valid.
-
Run this command:
terraform plan
You will see a detailed list of resources. No changes will be made at this step. If the configuration contains any errors, Terraform will show them.
-
Apply the changes:
terraform apply
-
Type
yes
and press Enter to confirm the changes.
-
You can check the container's update and settings using the management console
yc serverless container revision get <container_revision_ID>
To mount an ephemeral disk, use the deployRevision REST API method for the Container resource or the ContainerService/DeployRevision gRPC API call.