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
Yandex Compute Cloud
    • All guides
      • Creating a fixed-size instance group
      • Creating a fixed-size instance group with a network load balancer
      • Creating a fixed-size instance group with an L7 load balancer
      • Creating an autoscaling instance group
      • Creating an instance group with Container Optimized Image
      • Creating an instance group based on a YAML specification
      • Creating an instance group in a placement group
      • Creating a group of instances with fixed IP addresses
      • Creating an instance group connected to a file storage
      • Creating an instance group connected to Object Storage
    • Viewing operations with resources
  • Yandex Container Solution
  • Access management
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes
  1. Step-by-step guides
  2. Placement groups
  3. Creating an instance group in a placement group

Creating an instance group in a placement group

Written by
Yandex Cloud
Updated at May 5, 2025

You can create an instance group in a placement group.

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 be able to create, update, and delete VMs in the group, assign the compute.editor role to the service account.

CLI
API

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

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.

  1. See the description of the CLI command for creating a placement group:

    yc compute placement-group create --help
    
  2. Create a placement group in the default folder with one of the following placement strategies:

    • Spread placement:

      yc compute placement-group create \
        --spread-strategy \
        --name <placement_group_name>
      

      Where:

      • --spread-strategy: Shows that spread placement is selected.
      • --name: Placement group name.
    • Partition placement:

      yc compute placement-group create \
        --partitions <number_of_partitions> \
        --name <placement_group_name>
      

      Where:

      • --partitions: Shows that partition placement is selected, indicating the number of partitions from 1 to 5.
      • --name: Placement group name.
  3. See the description of the CLI command for creating an instance group:

    yc compute instance-group create --help
    
  4. Make sure the folder contains at least one network:

    yc vpc network list
    

    If there are no networks, create one.

  5. Select one of the Yandex Cloud Marketplace public images, e.g., CentOS 7.

    To get a list of available images using the CLI, run this command:

    yc compute image list --folder-id standard-images
    

    Result:

    +----------------------+-------------------------------------+--------------------------+----------------------+--------+
    |          ID          |                NAME                 |          FAMILY          |     PRODUCT IDS      | STATUS |
    +----------------------+-------------------------------------+--------------------------+----------------------+--------+
    ...
    | fdvk34al8k5n******** | centos-7-1549279494                 | centos-7                 | dqni65lfhvv2******** | READY  |
    | fdv7ooobjfl3******** | windows-2016-gvlk-1548913814        | windows-2016-gvlk        | dqnnc72gj2is******** | READY  |
    | fdv4f5kv5cvf******** | ubuntu-1604-lts-1549457823          | ubuntu-1604-lts          | dqnnb6dc7640******** | READY  |
    ...
    +----------------------+-------------------------------------+--------------------------+----------------------+--------+
    

    Where:

    • ID: Image ID.

    • NAME: Image name.

    • FAMILY: ID of the image family the image belongs to.

    • PRODUCT IDS: IDs of Yandex Cloud Marketplace products associated with the image.

    • STATUS: Current status of the image. It may take one of the following values:

      • STATUS_UNSPECIFIED: Image status is not defined.
      • CREATING: Image is being created.
      • READY: Image is ready to use.
      • ERROR: You cannot use the image due to an issue.
      • DELETING: Image is being deleted.
  6. Create a YAML file with any name, e.g., specification.yaml.

  7. Define the following in the file you created:

    • General information about the instance group:

      name: first-fixed-group
      service_account_id: <service_account_ID>
      description: "This instance group was created from YAML config."
      

      Where:

      • name: Instance group name. The name must be unique within the folder. It can only contain lowercase Latin letters, numbers, and hyphens. The first character must be a letter. The last character cannot be a hyphen. The name can be up to 63 characters long.

      • service_account_id: Service account ID.

        To be able to create, update, and delete VMs in the group, assign the compute.editor role to the service account.

        You cannot delete a service account while it is linked to an instance group.

      • description: Instance group description.

    • Instance template, such as the following:

      instance_template:
        platform_id: standard-v3
        resources_spec:
          memory: 2g
          cores: 2
        boot_disk_spec:
          mode: READ_WRITE
          disk_spec:
            image_id: fdvk34al8k5n********
            type_id: network-hdd
            size: 32g
        network_interface_specs:
          - network_id: c64mknqgnd8a********
            primary_v4_address_spec: {}
            security_group_ids:
              - enps0ar5s3ti********
        scheduling_policy:
          preemptible: false
        placement_policy:
          placement_group_id: fdvte50kv3nc********
      

      By default, the disk size is specified in bytes. You can specify a different unit of measurement using the applicable suffix.

      Suffix Prefix and multiplier Example
      k kilo- (210) 640k = 640 × 210 = 655360
      m mega- (220) 48m = 48 × 220 = 50331648
      g giga- (230) 10g = 10 × 230 = 10737418240
      t tera- (240) 4t = 4 × 240 = 4398046511104
      p peta- (250) 2p = 2 × 250 = 2251799813685248

      Where:

      • platform_id: Platform ID.

      • memory: Amount of RAM.

      • cores: Number of vCPUs.

      • mode: Disk access mode.

        • READ_ONLY: Read-only access.
        • READ_WRITE: Read/write access.
      • image_id: Public image ID. You can view image IDs in the management console when creating an instance or in Cloud Marketplace on the image page under Product IDs.

      • type_id: Disk type.

      • size: Disk size.

      • network_id: default-net network ID.

      • primary_v4_address_spec: IPv4 specification. You can allow public access to the group instances by specifying the IP version for the public IP address. For more information, see Template description in a YAML file.

      • security_group_ids: List of security group IDs.

      • scheduling_policy: Scheduling policy configuration.

      • preemptible: Flag for creating preemptible instances.

        • true: Create a preemptible instance.
        • false (default): Create a regular instance.

        When creating a preemptible instance group, keep in mind that the VM instances will terminate after 24 hours of continuous operation or earlier. Instance Groups may not be able to restart them immediately due to insufficient resources. This may occur in the event of a sharp increase in the use of Yandex Cloud computing resources.

      • placement_policy: Instance placement group parameters:

        • placement_group_id: Placement group ID.
    • Policies:

      deploy_policy:
        max_unavailable: 1
        max_expansion: 0
      scale_policy:
        fixed_scale:
          size: 3
      allocation_policy:
        zones:
          - zone_id: ru-central1-a
            instance_tags_pool:
            - first
            - second
            - third
      

      Where:

      • deploy_policy: Instance deployment policy for the group.
      • scale_policy: Instance scaling policy for the group.
      • allocation_policy: Policy for allocating instances across availability zones.

    Full code for the specification.yaml file:

    name: first-fixed-group
    service_account_id: <service_account_ID>
    description: "This instance group was created from YAML config."
    instance_template:
      platform_id: standard-v3
      resources_spec:
        memory: 2g
        cores: 2
      boot_disk_spec:
        mode: READ_WRITE
        disk_spec:
          image_id: fdvk34al8k5n********
          type_id: network-hdd
          size: 32g
      network_interface_specs:
        - network_id: c64mknqgnd8a********
          primary_v4_address_spec: {}
          security_group_ids:
            - enps0ar5s3ti********
       scheduling_policy:
         preemptible: false
       placement_policy:
         placement_group_id: fdvte50kv3nc********
    deploy_policy:
      max_unavailable: 1
      max_expansion: 0
    scale_policy:
      fixed_scale:
        size: 3
    allocation_policy:
      zones:
        - zone_id: ru-central1-a
          instance_tags_pool:
          - first
          - second
          - third
    
  8. Create an instance group in the default folder:

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

    This command will create a group of three same-type instances with the following configuration:

    • Name: first-fixed-group.
    • OS: CentOS 7.
    • Network: default-net.
    • Placement group: my-group.
    • Availability zone: ru-central1-a.
    • vCPUs: 2; RAM: 2 GB.
    • Network HDD: 32 GB.

Use the create REST API method for the InstanceGroup resource or the InstanceGroupService/Create gRPC API call.

Was the article helpful?

Previous
Creating a VM in a placement group
Next
Adding a VM to a placement group
Yandex project
© 2025 Yandex.Cloud LLC