Yandex Cloud
  • Services
  • Solutions
  • Why Yandex Cloud
  • Blog
  • Pricing
  • Documentation
  • Contact us
Get started
Language / Region
Yandex project
© 2023 Yandex.Cloud LLC
Yandex Serverless Containers
  • Comparison with other Yandex Cloud services
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Getting an IAM token for a service account using a container
    • Getting information about a container
    • Managing rights to access a container
    • Creating a container
      • Creating a container
      • Creating a container revision
    • Invoking a container
    • Managing a container
    • Getting information about a trigger
    • Creating a trigger
    • Managing triggers
  • Concepts
  • Practical guidelines
  • Access management
  • Pricing policy
  • Containers API reference
  • API Triggers reference
  • Questions and answers
  1. Step-by-step instructions
  2. Creating a container
  3. Creating a container revision

Creating a container revision

Written by
Yandex Cloud

    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.

    Management console
    CLI
    API
    Terraform
    1. In the management console, select the folder with your container.
    2. Select Serverless Containers.
    3. Select the container to create a revision for.
    4. Go to the Editor tab.
    5. Specify the revision parameters.
    6. 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 of concurrency, 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:

    1. 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.

    2. Make sure that the configuration files are valid.

      1. In the command line, switch to the folder where you created the configuration file.

      2. 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.

    3. If the configuration doesn't contain any errors, run the command:

      terraform apply
      
    4. 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
      

    Was the article helpful?

    Language / Region
    Yandex project
    © 2023 Yandex.Cloud LLC