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. - In the Ephemeral disk section, click Add ephemeral disk and specify in the field:
- Mount point: Name of the mount point. 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 disks will become unavailable. To mount the ephemeral disk correctly, provide the full absolute path to the mount point.
- Disk size: Memory size to allocate for the ephemeral disk being mounted.
- Click Create revision.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder 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_amount> \
--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 mounted file system.mount-point
: Name of the mount point. 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 disks 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
.
Terraform
For more information about the provider resources, see the documentation on the Terraform
If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.
If you don't have Terraform, 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_amount>" execution_timeout = "<execution_timeout>" service_account_id = "<service_account_ID>" content { zip_filename = "<path_to_ZIP_archive>" } mounts { mount_point_path = <mount_point> ephemeral_disk { size_gb = <disk_size> } } image { url = <container_image_path> } }
Where:
mounts
: Ephemeral disk mounting parameters:mount_point_path
: Name of the mount point. 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 disks 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 the provider documentation . -
Apply the changes:
-
In the terminal, change to the folder where you edited the configuration file.
-
Make sure the configuration file is correct using the command:
terraform validate
If the configuration is correct, the following message is returned:
Success! The configuration is valid.
-
Run the command:
terraform plan
The terminal will display a list of resources with parameters. No changes are made at this step. If the configuration contains errors, Terraform will point them out.
-
Apply the configuration changes:
terraform apply
-
Confirm the changes: type
yes
in the terminal and press Enter.
-
You can check the container update and its new configurations using the management console
yc serverless container version get <container_ID>
To mount an ephemeral disk, use the deployRevision REST API method for the Container resource or the ContainerService/DeployRevision gRPC API call.