Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
Tutorials
    • All tutorials
    • Basic internet service architecture and protection
    • Cost analysis by resource using Object Storage
      • Configuring a fault-tolerant architecture in Yandex Cloud
      • Integrating an L7 load balancer with Cloud CDN and Object Storage
      • Autoscaling an instance group to process messages enqueued in Message Queue
      • Updating an instance group under load
      • Creating a budget trigger that invokes a function to stop a VM
      • Deploying a fault-tolerant architecture with preemptible VMs
      • Creating triggers that invoke a function to stop a VM and send a Telegram notification

In this article:

  • Get your cloud ready
  • Required paid resources
  • Prepare the environment
  • Create a Container Optimized Image instance group
  • Add a network load balancer to the instance group you created
  • Create a load on a VM
  • Update the instance group under load
  • Stop the load and get the results
  • How to delete the resources you created
  1. Basic infrastructure
  2. Fault tolerance and scaling
  3. Updating an instance group under load

Updating an instance group under load

Written by
Yandex Cloud
Updated at May 5, 2025
  • Get your cloud ready
    • Required paid resources
  • Prepare the environment
  • Create a Container Optimized Image instance group
    • Add a network load balancer to the instance group you created
  • Create a load on a VM
  • Update the instance group under load
  • Stop the load and get the results
  • How to delete the resources you created

In this step-by-step tutorial, you will configure an instance group and check how it operates when updating the configuration. To do this:

  1. Get your cloud ready.
  2. Prepare the environment.
  3. Create an instance group from a Container Optimized Image.
  4. Create a load on a VM.
  5. Update the instance group under load.
  6. Stop the load and get the results.

If you no longer need the resources you created, delete them.

Get your cloud readyGet your cloud ready

  1. If you do not have the Yandex Cloud CLI yet, install it.

  2. To make sure the scripts from the step-by-step guide run correctly, download and install jq.

  3. To check autoscaling, install wrk.

Required paid resourcesRequired paid resources

The support cost for a Yandex Cloud instance group includes fees for:

  • Disks and continuously running VMs as per Yandex Compute Cloud pricing.
  • Using a dynamic or static public IP address as per Yandex Virtual Private Cloud pricing.

Prepare the environmentPrepare the environment

  1. Create a service account named for-load. To create, update, and delete VMs in the group, as well as integrate the group with an Network Load Balancer network load balancer, assign the compute.editor and load-balancer.editor roles to the service account:

    Management console
    CLI
    API
    1. In the management console, select the folder where you want to create your service account.
    2. From the list of services, select Identity and Access Management.
    3. Click Create service account.
    4. In the Name field, specify for-load.
    5. Click Add role. To create, update, and delete VMs in the group, as well as integrate the group with an Network Load Balancer network load balancer, assign the compute.editor and load-balancer.editor roles to a service account.
    6. Click Create.
    1. Create a service account:

      The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

      yc iam service-account create --name for-load
      

      Result:

      id: ajeab0cnib1p********
      folder_id: b0g12ga82bcv********
      created_at: "2021-02-09T17:31:32.561702Z"
      name: for-load
      
    2. Assign the compute.editor role to the service account:

      yc resource-manager folder add-access-binding <folder_ID> \
        --role compute.editor \
        --subject serviceAccount:<service_account_ID>
      
    3. Assign the load-balancer.editor role to the service account:

      yc resource-manager folder add-access-binding <folder_ID> \
        --role load-balancer.editor \
        --subject serviceAccount:<service_account_ID>
      
    1. Create a service account named for-load:
      Use the create REST API method for the ServiceAccount resource or the ServiceAccountService/Create gRPC API call.
    2. To create, update, and delete VMs in the group, as well as integrate the group with an Network Load Balancer network load balancer, assign the compute.editor and load-balancer.editor roles to the service account:
      Use the setAccessBindings REST API method for the Folder resource or the FolderService/SetAccessBindings gRPC API call.
  2. Create a network named yc-auto-network and subnets in two availability zones:

    Management console
    CLI
    API
    1. In the management console, select the folder where you want to create a network.
    2. From the list of services, select Virtual Private Cloud.
    3. Click Create network.
    4. In the Name field, specify yc-auto-network.
    5. Select Create subnets.
    6. Click Create network.
    1. Create a network:

      yc vpc network create --name yc-auto-network
      

      Result:

      id: enpabce123hd********
      folder_id: b0g12ga82bcv********
      created_at: "2021-02-09T17:33:32.561702Z"
      name: yc-auto-network
      
    2. Create a subnet in the ru-central1-d availability zone:

      yc vpc subnet create --network-id enpabce123hd******** --range 192.168.1.0/24 --zone ru-central1-d
      

      Result:

      id: e1lnabc23r1c********
      folder_id: b0g12ga82bcv********
      created_at: "2021-02-09T17:34:32.561702Z"
      network_id: enpabce123hd********
      zone_id: ru-central1-d
      v4_cidr_blocks:
      - 192.168.1.0/24
      
    3. Create a subnet in the ru-central1-b availability zone:

      yc vpc subnet create --network-id enpabce123hd******** --range 192.168.2.0/24 --zone ru-central1-b
      

      Result:

      id: b1csa2b3clid********
      folder_id: b0g12ga82bcv********
      created_at: "2021-02-09T17:35:32.561702Z"
      network_id: enpabce123hd********
      zone_id: ru-central1-b
      v4_cidr_blocks:
      - 192.168.2.0/24
      
    1. Create a network:
      Use the create REST API method for the Network resource or the NetworkService/Create gRPC API call.
    2. Create subnets in the ru-central1-d and ru-central1-b availability zones:
      Use the create REST API method for the Subnet resource or the SubnetService/Create gRPC API call.

Create a Container Optimized Image instance groupCreate a Container Optimized Image instance group

  1. You will be creating all instance groups from Container Optimized Images. Each VM will have a Docker container running a web server that emulates the load.

    Management console
    CLI
    API
    1. In the management console, select a folder where your instance group will reside.
    2. From the list of services, select Compute Cloud.
    3. In the left-hand panel, select Instance groups.
    4. Click Create group of virtual machines.
    5. Under Basic parameters:
      • In the Name field, specify group-for-load.
      • Select Service account for-load.
    6. Under Allocation, select ru-central1-d and ru-central1-b in the Availability zone field.
    7. Under Instance template, click Define and do the following in the window that opens:
      • Under Boot disk image, select the Container Solution tab.
      • Click Configure.
      • In the Docker container settings window:
        • In the Name field, specify nginx.
        • In the Docker image field, click Enter link and enter cr.yandex/yc/demo/autoscaling-example-app:v1.
        • Click Apply.
      • Under Disks and file storages:
        • For the boot disk, specify a Size of 30 GB.
      • Under Network settings:
        • In the Network field, select for-load.
      • Under Access:
        • In the Service account field, select for-load.
        • In the Login field, enter the name of the user to create on the VM.
        • In the SSH key field, paste the contents of the public key file.
      • Click Save.
    8. Under Changes during creation and updates:
      • In the Reduce below target value field, enter 4.
    9. Under Scaling:
      • In the Type field, select Fixed.
      • Set the Size to 6.
    10. Under Integration with Network Load Balancer:
      • Enable Create target group.
      • In the Name of the target group field, specify load-generator.
    11. Click Create.
    1. Get the ID of the latest version of the public Container Optimized Image.

      A Container Optimized Image in Yandex Container Registry may get updates and modifications that come with new releases. Such modifications will not automatically update the VM image to the latest version. To create an instance group with the latest Container Optimized Image version, check whether it is available on your own:

      yc compute image get-latest-from-family container-optimized-image --folder-id standard-images
      

      Result:

      id: fd8iv792kira********
      folder_id: standard-images
      created_at: "2021-01-29T13:30:22Z"
      ...
      status: READY
      os:
        type: LINUX
      
    2. Save the specification of the instance group with a network load balancer to the specification.yaml file:

      name: group-for-load # VM group name, unique within the folder.
      service_account_id: ajeab0cnib1p******** # Service account ID.
      allocation_policy: # VM allocation policy for the group.
         zones:
           - zone_id: ru-central1-d
           - zone_id: ru-central1-b
      instance_template:
        service_account_id: ajeab0cnib1p******** # ID of the service account to access private Docker images.
        platform_id: standard-v1 # Platform ID.
        resources_spec:
          memory: 2G # Amount of memory (RAM).
          cores: 2 # Number of processor cores (vCPUs).
        boot_disk_spec:
          mode: READ_WRITE # Disk access mode (read and write).
          disk_spec:
            image_id: <latest_COI_version_ID>
          type_id: network-ssd # Disk type.
          size: 30G # Disk size.
        network_interface_specs:
         - network_id: enplhg4nncc7******** # Network ID.
           subnet_ids:
             - e1lnabc23r1c******** # Subnet ID.
             - b1csa2b3clid********
           primary_v4_address_spec: {
             one_to_one_nat_spec: {
               ip_version: IPV4 # IPv4 specification for public access to the VM.
             }
           }         
        metadata: # Values to send to the VM metadata.
          docker-container-declaration: |- # Key in the VM metadata that is used with the Docker Container specification.
            spec:
              containers:
                - image: cr.yandex/yc/demo/autoscaling-example-app:v1
                  name: nginx
                  securityContext:
                    privileged: false
                  restartPolicy: Always
                  tty: false
                  stdin: false
          ssh-keys: | # Parameter for providing an SSH key to the VM.
            yc-user:ssh-ed25519 ABC...d01 user@desktop.ru # Username for connecting to the VM.
      deploy_policy: # VM deployment policy for the group.
        max_unavailable: 4
      scale_policy: # Instance scaling policy for the group.
        fixed_scale:
          size: 6
      load_balancer_spec: # Network load balancer.
        target_group_spec:
          name: load-generator
      

      Note

      You can provide an SSH key in the VM metadata using the ssh-keys parameter or in the user-data key with the user metadata. This tutorial features the first option.

    3. Create an instance group named group-for-load using specification.yaml:

      yc compute instance-group create --file=specification.yaml
      

      Result:

      done (2m18s)
      id: cl0kabcquk1g********
      folder_id: b0g12ga82bcv********
      ...
      service_account_id: ajeab0cnib1p********
      status: ACTIVE
      application_load_balancer_state: {}
      
    1. Get the ID of the latest container-optimized-image version in the standard-images family:
      Use the getLatestByFamily REST API method for the Image resource or the ImageService/GetLatestByFamily gRPC API call.

    2. Create an instance group based on this spec:

      name: group-for-load # VM group name, unique within the folder.
      service_account_id: ajeab0cnib1p******** # Service account ID.
      allocation_policy: # VM allocation policy for the group.
         zones:
           - zone_id: ru-central1-d
           - zone_id: ru-central1-b
      instance_template:
        service_account_id: ajeab0cnib1p******** # ID of the service account to access private Docker images.
        platform_id: standard-v1 # Platform ID.
        resources_spec:
          memory: 2G # Amount of memory (RAM).
          cores: 2 # Number of processor cores (vCPUs).
        boot_disk_spec:
          mode: READ_WRITE # Disk access mode (read and write).
          disk_spec:
            image_id: <latest_COI_version_ID>
          type_id: network-ssd # Disk type.
          size: 30G # Disk size.
        network_interface_specs:
         - network_id: enplhg4nncc7******** # Network ID.
           subnet_ids:
             - e1lnabc23r1c******** # Subnet ID.
             - b1csa2b3clid********
           primary_v4_address_spec: {
             one_to_one_nat_spec: {
               ip_version: IPV4 # IPv4 specification for public access to the VM.
             }
           }         
        metadata: # Values to send to the VM metadata.
          docker-container-declaration: |- # Key in the VM metadata that is used with the Docker Container specification.
            spec:
              containers:
                - image: cr.yandex/yc/demo/autoscaling-example-app:v1
                  name: nginx
                  securityContext:
                    privileged: false
                  restartPolicy: Always
                  tty: false
                  stdin: false
          ssh-keys: | # Parameter for providing an SSH key to the VM.
            yc-user:ssh-ed25519 ABC...d01 user@desktop.ru # Username for connecting to the VM.
      deploy_policy: # VM deployment policy for the group.
        max_unavailable: 4
      scale_policy: # Instance scaling policy for the group.
        fixed_scale:
          size: 6
      load_balancer_spec: # Network load balancer.
        target_group_spec:
          name: load-generator
      

      Use the createFromYaml REST API method for the InstanceGroup resource or the InstanceGroupService/CreateFromYaml gRPC API call.

  2. Make sure you have created the instance group:

    Management console
    CLI
    API
    1. In the management console, select the folder where you created the instance group.
    2. From the list of services, select Compute Cloud.
    3. In the left-hand panel, select Instance groups.
    4. Click group-for-load.
    yc compute instance-group list-instances group-for-load
    

    Result:

    +----------------------+---------------------------+-----------------+-------------+----------------------+----------------+
    |     INSTANCE ID      |           NAME            |   EXTERNAL IP   | INTERNAL IP |        STATUS        | STATUS MESSAGE |
    +----------------------+---------------------------+-----------------+-------------+----------------------+----------------+
    ...
    | fhmab0cfsfd1******** | cl0kabcquk1g********-oxig | 178.154.226.108 | 10.130.0.8  | RUNNING_ACTUAL [49m] |                |
    | epdabchpdef0******** | cl0kabcquk1g********-aqyg | 130.193.40.55   | 10.129.0.20 | RUNNING_ACTUAL [43m] |                |
    +----------------------+---------------------------+-----------------+-------------+----------------------+----------------+
    

    To view the list of the instance groups you created, use the list REST API method for the InstanceGroup resource or the InstanceGroupService/List gRPC API call.

Add a network load balancer to the instance group you createdAdd a network load balancer to the instance group you created

  1. Create a network load balancer named load-generator and connect it to the instance group you created:

    Management console
    CLI
    API
    1. In the management console, select the folder where you want to create a load balancer.
    2. From the list of services, select Network Load Balancer.
    3. Click Create a network load balancer.
    4. In the Name field, specify load-generator.
    5. In the Public address field, select Auto.
    6. Under Listeners, click Add listener.
    7. In the window that opens:
      • In the Name field, specify http.
      • In the Port field, enter 80 as the port where the balancer will receive inbound traffic.
      • In the Target port field, enter 80 as the port to which the balancer will redirect traffic.
      • Click Add.
    8. Under Target groups, click Add target group.
    9. In the Target group list, select load-generator.
    10. Under Health check, click Configure:
      • In the window that opens, specify: /hello as the Path. The load balancer will use this path to send health check requests to the target group VMs.
      • Click Apply.
    11. Click Create.
    1. Get the ID of the load-generator target group:

      yc load-balancer target-group get load-generator | grep "^id"
      

      Result:

      id: enpsa475ej51********
      
    2. Create a network load balancer:

      yc load-balancer network-load-balancer create \
        --name load-generator \
        --listener external-ip-version=ipv4,name=http,port=80,protocol=tcp,target-port=80 \
        --target-group healthcheck-http-port=80,healthcheck-http-path=/hello,target-group-id=<target_group_ID>
      

      Result:

      done (14s)
      id: b0ruab1ccvpd********
      folder_id: b1csa2b3clid********
      ...
          healthy_threshold: "2"
          http_options:
            port: "80"
            path: /hello
      
    1. Create a load balancer using the create REST API method for the NetworkLoadBalancer resource or the NetworkLoadBalancerService/Create gRPC API call.
    2. Add a listener to the load balancer using the addListener REST API method for the NetworkLoadBalancer resource or the NetworkLoadBalancerService/AddListener gRPC API call.
    3. Connect the target group to the load balancer using the attachTargetGroup REST API method for the NetworkLoadBalancer resource or the NetworkLoadBalancerService/AttachTargetGroup gRPC API call.
    4. Add the load balancer to the instance group using the addTargets REST API method for the TargetGroup resource or the TargetGroupService/AddTargets gRPC API call.
  2. Make sure you created the network load balancer named load-generator and linked it to the instance group:

    Management console
    CLI
    API
    1. In the management console, select the folder where you created the load balancer.
    2. From the list of services, select Network Load Balancer.
    3. Click load-generator .
    yc load-balancer network-load-balancer list
    

    Result:

    +----------------------+----------------+-----------------+----------+----------------+------------------------+--------+
    |          ID          |      NAME      |    REGION ID    |   TYPE   | LISTENER COUNT | ATTACHED TARGET GROUPS | STATUS |
    +----------------------+----------------+-----------------+----------+----------------+------------------------+--------+
    | b0ruab1ccvpd******** | load-generator | ru-central1     | EXTERNAL |              1 | b0r1tabcphde********   | ACTIVE |
    +----------------------+----------------+-----------------+----------+----------------+------------------------+--------+
    

    Use the list REST API method for the NetworkLoadBalancer resource or the NetworkLoadBalancerService/List gRPC API call.

Create a load on a VMCreate a load on a VM

  1. Get the IP address of the load balancer you created:

    Management console
    CLI
    API
    1. In the management console, select the load balancer folder.
    2. From the list of services, select Network Load Balancer.
    3. Copy the IP address of the load-generator load balancer.
    yc load-balancer network-load-balancer get load-generator | grep "address"
    

    Result:

      address: 84.252.133.110
    

    Use the get REST API method for the NetworkLoadBalancer resource or the NetworkLoadBalancerService/Get gRPC API call.

  2. Run this command to create a load:

    wrk -t20 -c20 -d20m --timeout 20s http://<load_balancer_IP_address>/sleep
    

    The command will launch the wrk utility that will send requests to 20 threads using 20 connections to the network load balancer for 20 minutes. The request timeout is 20 seconds. The load balancer will distribute the load it gets among the group’s VMs.

    After you launch wrk, a testing start message will appear on the screen:

    Running 20m test @ http://84.252.133.110/sleep
      20 threads and 20 connections
    

    Proceed to the next step without waiting for the command to complete.

Update the instance group under loadUpdate the instance group under load

Management console
CLI
API
  1. In the management console, select the folder where you created the instance group.
  2. Select Compute Cloud.
  3. In the left-hand panel, select Instance groups.
  4. Click group-for-load.
  5. Click Edit.
  6. Under Instance template, click and select Edit.
    • Under Disks and file storages, enter the new disk size of 35 GB.
    • Click Save.
  7. Click Save.
  8. Under VM states, you will see the disk size modifications for all VMs in the instance group, one by one.
  1. In specification.yaml, enter the new disk size of 35 GB and save the file:

    ...
    size: 35G
    ...
    
  2. Update the instance group:

    yc compute instance-group update --name=group-for-load --file=specification.yaml
    

    Result:

    done (9m24s)
    id: cl10kktrjcn8********
    folder_id: b1g7gvsi89m3********
    ...
       name: load-generator
    service_account_id: ajehbk07uus3********
    status: ACTIVE
    
  1. In the spec, enter the new disk size of 35 GB:

    ...
    size: 35G
    ...
    
  2. To update the load-generator instance group based on the new spec, use the updateFromYaml REST API method for the InstanceGroup resource or the InstanceGroupService/UpdateFromYaml gRPC API call.

Stop the load and get the resultsStop the load and get the results

Stop wrk by pressing Ctrl + C.

Result:

  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    10.00s     1.70ms  10.01s    68.21%
    Req/Sec     0.00      0.00     0.00    100.00%
  1148 requests in 17.47m, 211.89KB read
Requests/sec:      1.09
Transfer/sec:     206.94B

If the result contains no error line, such asSocket errors, it means the system has processed all requests.

How to delete the resources you createdHow to delete the resources you created

To delete the created resources:

Management console
CLI
API
  1. Delete the load balancer:
    1. In the management console, select the folder you created the load balancer in.
    2. From the list of services, select Network Load Balancer.
    3. To the right of the load-generator line, click and select Delete.
    4. In the window that opens, click Delete.
  2. Delete the instance group:
    1. In the management console, select the folder where you created the instance group.
    2. From the list of services, select Compute Cloud.
    3. In the left-hand panel, select Instance groups.
    4. To the right of the load-generator line, click and select Delete.
    5. In the window that opens, click Delete.
  3. Delete the service account:
    1. In the management console, select the folder where you created the service account.
    2. From the list of services, select Identity and Access Management.
    3. In the left-hand panel, select Service accounts.
    4. In the list that opens, click and select Delete in the row with the yc-auto-sa service account.
    5. In the window that opens, click Delete.
  4. Delete the network and subnets:
    1. In the management console, select the folder where you created the network and subnets.
    2. From the list of services, select Virtual Private Cloud.
    3. Select yc-auto-network.
    4. Under Subnets:
      1. To the right of the yc-auto-subnet-1 line, click and select Delete.
      2. In the window that opens, click Delete.
      3. Delete the yc-auto-subnet-2 subnet as well.
    5. In the top-right corner, click Delete.

Run these commands one by one:

yc load-balancer network-load-balancer delete load-generator
yc compute instance-group delete load-generator
yc iam service-account delete yc-auto-sa
yc vpc subnet delete yc-auto-subnet-1
yc vpc subnet delete yc-auto-subnet-2
yc vpc network delete yc-auto-network
  1. Delete the load-generator load balancer using the delete REST API method for the NetworkLoadBalancer resource or the NetworkLoadBalancerService/Delete gRPC API call.
  2. Delete the load-generator instance group using the delete REST API method for the InstanceGroup resource or the InstanceGroupService/Delete gRPC API call.
  3. Delete the yc-auto-sa service account using the delete REST API method for the ServiceAccount resource or the ServiceAccountService/Delete gRPC API call.
  4. Delete the yc-auto-subnet-1 and yc-auto-subnet-2 subnets using the delete REST API method for the Subnet resource or the SubnetService/Delete gRPC API call.
  5. Delete the yc-auto-network network using the delete REST API method for the Network resource or the NetworkService/Delete gRPC API call.

Was the article helpful?

Previous
Autoscaling an instance group to process messages enqueued in Message Queue
Next
Creating a budget trigger that invokes a function to stop a VM
Yandex project
© 2025 Yandex.Cloud LLC