Creating a container revision
You need to create a new revision:
- When you upload a new Docker image version to Container Registry.
- When you modify revision settings.
Note
To ensure the integrity of version links, you can't update or delete container revisions. When creating a new container revision, the previous one becomes obsolete and unavailable for invocations.
If a registry or repository containing the Docker image is not public, you need to specify a service account with permission to download the Docker image in the revision settings. For example, the container-registry.images.puller
role to the folder or registry containing the Docker image.
If a service account is specified in the revision settings, the user or the service account creating the revision must have the iam.serviceAccounts.user
role. It confirms the right to use the service account.
- In the management console, select the folder with your container.
- Select Serverless Containers.
- Select the container to create a revision for.
- Go to the Editor tab.
- Specify the revision parameters.
- Click Create revision.
To create a container revision, run the command:
yc serverless container revision deploy \
--container-name <container_name> \
--image <Docker_image_URL> \
--cores 1 \
--memory 1GB \
--concurrency 1 \
--execution-timeout 30s \
--service-account-id <service_account_ID>
Where:
-
--cores
: Number of cores available for the container. -
--memory
: Required memory. The default is 128 MB. -
--concurrency
: Maximum number of concurrent requests to a single container instance. Default is 1 and maximum value is 16. If the number of requests to a container exceeds the value ofconcurrency
, Serverless Containers scales the container up by launching additional copies.Note
The number of container instances and concurrent container requests in each zone cannot exceed the quota.
-
--execution-timeout
: Timeout. Default is 3 seconds. -
--service-account-id
: ID of service account with authorization to download an image.
Result:
id: bbajn5q2d74c********
container_id: bba3fva6ka5g********
created_at: "2021-07-09T15:04:55.135Z"
image:
image_url: cr.yandex/crpd3cicopk7********/test-container:latest
image_digest: sha256:de8e1dce7ceceeafaae122f7670084a1119c961cd9ea1795eae92bd********
resources:
memory: "1073741824"
cores: "1"
execution_timeout: 3s
service_account_id: ajeqnasj95o7********
status: ACTIVE
You can create a container revision using the deployRevision API method.
With Terraform, you can quickly create a cloud infrastructure in Yandex Cloud and manage it by configuration files. They store the infrastructure description in HashiCorp Configuration Language (HCL). Terraform and its providers are distributed under the Mozilla Public License.
For more information about the provider resources, see the documentation on the Terraform site or mirror site.
If you change the configuration files, Terraform automatically determines 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.
In Terraform, a new revision is created every time the resource's runtime parameters are updated.
To create a revision:
-
Update the
yandex_serverless_container
resource runtime parameters in the configuration file:provider "yandex" { token = "<OAuth>" cloud_id = "<cloud ID>" folder_id = "<folder ID>" zone = "ru-central1-a" } resource "yandex_serverless_container" "test-container" { name = "<container name>" memory = <memory size> service_account_id = "<service account ID>" image { url = "<Docker image URL>" } }
For more information about the
yandex_serverless_container
resource in Terraform, see the provider documentation. -
Make sure that the configuration files are valid.
-
In the command line, switch to the folder where you created the configuration file.
-
Run the check using the command:
terraform plan
If the configuration is described correctly, the terminal displays a list of resources being created or updated and their parameters. If the configuration contains errors, Terraform will point them out.
-
-
If the configuration doesn't contain any errors, run the command:
terraform apply
-
Confirm the resource creation or update by typing
yes
in the terminal and pressing Enter.This will create the revision. You can verify that the revision has been created in the management console or with the following CLI command:
yc serverless container revision list