Recreating instances in a group one by one
You can recreate group instances one by one based on the parameters specified in the deployment policy.
For example, if the maximum number of unhealthy instances per group set in the deployment policy is 1
, then, when recreating instances one by one, only one instance will be unavailable at any given time.
Warning
With the manual instance stopping strategy, Instance Groups will restart or recreate an instance if at least one of the following conditions is met:
- User stops the instance in Compute Cloud.
- Application or user stops the instance internally.
- Instance fails the application health check.
To recreate group instances one by one:
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.
-
View a description of the CLI command to recreate an instance group:
yc compute instance-group rolling-recreate --help
-
Get a list of folders in the default cloud:
yc resource-manager folder list
Result:
+----------------------+--------------------+------------------+--------+ | ID | NAME | LABELS | STATUS | +----------------------+--------------------+------------------+--------+ | b1gd129pp9ha******** | my-folder | | ACTIVE | | b1g66mft1vop******** | default | | ACTIVE | +----------------------+--------------------+------------------+--------+
-
Get a list of instance groups in the selected folder by specifying its name:
yc compute instance-group list \ --folder-name <folder_name>
Result:
+----------------------+-----------------------+--------+------+ | ID | NAME | STATUS | SIZE | +----------------------+-----------------------+--------+------+ | amc65sbgfqeq******** | first-instance-group | ACTIVE | 4 | +----------------------+-----------------------+--------+------+
-
Recreate instances in the instance group:
yc compute instance-group rolling-recreate --all \ --name <instance_group_name> \ --folder-name <folder_name>
Where:
--name
: Name of the instance group.--folder-name
: Name of the folder the instance group belongs to.
Instance Groups will begin to recreate all instances in the group one by one. The status of recreated instances will change to
Running
.Result:
done (2m43s) id: amc65sbgfqeq******** ... status: ACTIVE application_load_balancer_state: {}
To recreate individual instances in a group, get a list of instances in this group:
yc compute instance-group list-instances \ --name <instance_group_name> \ --folder-name <folder_name>
Where:
--name
: Name of the instance group.--folder-name
: Name of the folder the instance group belongs to.
Result:
+----------------------+---------------------------+----------------+--------------+------------------------+----------------+ | INSTANCE ID | NAME | EXTERNAL IP | INTERNAL IP | STATUS | STATUS MESSAGE | +----------------------+---------------------------+----------------+--------------+------------------------+----------------+ | epdl7gdvb69f******** | cl17k72ehu54********-amyk | 130.193.**.*** | 192.168.0.33 | RUNNING_ACTUAL [8m] | | | epdjtb04efcf******** | cl17k72ehu54********-oper | 84.201.***.*** | 192.168.0.17 | RUNNING_ACTUAL [6m] | | | epd3anghn4vb******** | cl17k72ehu54********-axec | 84.201.***.*** | 192.168.0.14 | RUNNING_ACTUAL [1m50s] | | | epdbt0c7o6d3******** | cl17k72ehu54********-ihez | 51.250.***.*** | 192.168.0.29 | RUNNING_ACTUAL [1m0s] | | +----------------------+---------------------------+----------------+--------------+------------------------+----------------+
Recreate the instances you need:
yc compute instance-group rolling-recreate \ --instance-ids <instance_IDs> \ --name <instance_group_name> \ --folder-name <folder_name>
Where:
--instance-ids
: Comma-separated list of IDs of instances to be recreated. For example, to recreate the first and third instances from the above list, specify--instance-ids epdl7gdvb69f********,epd3anghn4vb********
.--name
: Name of the instance group.--folder-name
: Name of the folder the instance group belongs to.
Instance Groups will begin to recreate the specified instances in the group one by one. The status of recreated instances will change to
Running
.
For more information about the yc compute instance-group rolling-recreate
command, see the CLI reference.
Use the rollingRecreate REST API method for the InstanceGroup resource or the InstanceGroupService/RollingRecreate gRPC API call.