Setting up automatic recovery for instances

    You can set up automatic recovery for a group of instances to enhance the availability of your application and make sure it is responding. You can set up automatic recovery for instances when creating or updating a group.

    You can only set up one health check for automatic recovery (don't confuse it with health checks for Yandex Load Balancer).

    By default, all operations in Instance Groups are performed on behalf of a service account. If you don't have a service account, create one.

    To enable automatic recovery when updating an instance group:

    1. Open the folder page in the management console.

    2. Select Yandex Compute Cloud.

    3. On the Virtual machines page, go to the Instance groups tab.

    4. Select the group to update.

    5. In the Health checks section, enable the Activate option to the right.

    6. Select the protocol for the health checks: HTTP or TCP.

      Indicate the following:

      • A port number in the range of 1-32767.

      • The URL to perform checks for (if HTTP is chosen).

      • The response timeout in seconds.

      • The interval between health checks in seconds.

      • The performance threshold, which is the number of successful health checks required for the managed instance to be considered healthy.

      • The failure threshold, which is the number of failed health checks for the managed instance to be considered unhealthy.

    7. Click Save changes.

    If you don't have the Yandex.Cloud command line interface yet, install 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 flag.

    1. See the description of the CLI's update group command:

      $ yc compute instance-group update --help
      
    2. Get a list of instance groups in the default folder:

      $ yc compute instance-group list
      +----------------------+-----------------------+------+
      |          ID          |         NAME          | SIZE |
      +----------------------+-----------------------+------+
      | amc65sbgfqeqf00m02sc | first-instance-group  |    2 |
      +----------------------+-----------------------+------+
      

      Fields:

      Field Value
      ID Group ID.
      NAME Group name.
      SIZE Group size.
    3. Select the ID or NAME of the group (for example, first-fixed-group).

    4. Get information about the instance group.

    5. Create a YAML file with any name (for example, group.yaml) and, based on the information received, describe:

    6. Add the health check specifications to the file:

      ...
      health_checks_spec:
        health_check_specs:
          - tcp_options:
              port: 80
            interval: 30s
            timeout: 10s
            unhealthy_threshold: 5
            healthy_threshold: 3
      ...
      

      Where:

      Key Value
      health_check_specs Health check specs.
      tcp_options TCP options.
      port A port number in the range of 1-32767.
      interval The interval between health checks in seconds.
      timeout The response timeout in seconds.
      unhealthy_threshold The failure threshold, which is the number of failed health checks for the managed instance to be considered unhealthy.
      healthy_threshold The performance threshold, which is the number of successful health checks required for the managed instance to be considered healthy.
    7. Update the instance group in the default folder:

      $ yc compute instance-group update --name first-group --file group.yaml
      

      Instance Groups starts the operation to update the instance group.