Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Solutions
  • Pricing
  • Documentation
  • Contact us
Get started
Yandex Compute Cloud
  • Getting started
    • Overview
    • Creating a Linux VM
    • Creating a Windows VM
    • Creating instance groups
  • Step-by-step instructions
    • All instructions
    • Creating VMs
      • Creating a Linux VM
      • Creating a Windows VM
      • Creating a VM from a set of disks
      • Creating a VM with disks restored from snapshots
      • Creating a VM from a custom image
      • Creating a preemptible VM
      • Creating a VM with a GPU
    • DSVM
      • Overview
      • Creating a VM from a public DSVM image
    • Placement groups
      • Creating a placement group
      • Deleting a placement group
      • Creating a VM in a placement group
      • Adding a VM to a placement group
      • Removing a VM instance from a placement group
    • Images with pre-installed software
      • Creating a VM from a public image
      • Configuring software
      • Working with a VM based on a public image
      • Getting a list of public images
    • Getting information about a VM
      • Getting information about a VM
      • Viewing serial port output
    • Managing VMs
      • Stopping and starting a VM
      • Attaching a disk to a VM
      • Detaching a disk from a VM
      • Moving a VM to a different availability zone
      • Making a VM's public IP address static
      • Updating a VM
      • Changing VM computing resources
      • Deleting a VM
    • Working on VMs
      • Connecting to a VM via SSH
      • Connecting to a VM via RDP
      • Working with Yandex.Cloud from inside a VM
      • Installing NVIDIA drivers
    • Creating new disks
      • Creating an empty disk
      • Create an empty disk with a large block
    • Disk management
      • Creating a disk snapshot
      • Updating a disk
      • Deleting a disk
      • Deleting a disk snapshot
    • Creating new images
      • Uploading your image
    • Managing images
      • Deleting a disk image
    • Managing the serial console
      • Getting started
      • Connecting to a serial console via SSH
      • Connecting to a serial console via CLI
      • Start your terminal in the Windows SAC
      • Disabling access to the serial console
    • Creating instance groups
      • Creating a fixed-size instance group
      • Creating a fixed-size instance group with a network load balancer
      • Creating an automatically scaled instance group
      • Creating an instance group from Container Optimized Image
    • Getting information about instance groups
      • Getting a list of instance groups
      • Getting information about an instance group
      • Getting a list of instances in a group
    • Managing instance groups
      • Editing an instance group
      • Configuring application health check on the VM
      • Updating a instance group
        • Incremental updates
        • Uninterrupted updates
      • Stopping an instance group
      • Starting an instance group
      • Deleting an instance group
    • Dedicated hosts
      • Creating a VM in a group of dedicated hosts
      • Creating a VM on a dedicated host
  • Yandex Container Optimized Solutions
  • Scenarios
    • Configuring NTP time synchronization
    • Running instance groups with auto scaling
  • Concepts
    • Relationship between resources
    • Virtual machines
      • Overview
      • Platforms
      • vCPU performance levels
      • Graphics accelerators (GPUs)
      • Preemptible VMs
      • Network on a VM
      • Live migration
      • Placement groups
      • Statuses
      • Metadata
    • Disks
      • Overview
      • Disk snapshots
    • Images
    • Instance groups
      • Overview
      • Access
      • Instance template
      • Variables in an instance template
      • Policies
        • Overview
        • Allocation policy
        • Deployment policy
        • Scaling policy
      • Scaling types
      • Auto-healing
      • Updating
        • Overview
        • Allocating instances across zones
        • Deployment algorithm
        • Rules for updating instance groups
      • Statuses
    • Dedicated host
    • Backups
    • Quotas and limits
  • Access management
  • Pricing policy
    • Current pricing policy
    • Archive
      • Before January 1, 2019
      • From January 1 to March 1, 2019
      • From March 1 to May 1, 2019
  • Compute API reference
    • Authentication in the API
    • gRPC
      • Overview
      • DiskPlacementGroupService
      • DiskService
      • DiskTypeService
      • HostGroupService
      • HostTypeService
      • ImageService
      • InstanceService
      • PlacementGroupService
      • SnapshotService
      • ZoneService
      • InstanceGroupService
      • OperationService
    • REST
      • Overview
      • Disk
        • Overview
        • create
        • delete
        • get
        • list
        • listOperations
        • update
      • DiskPlacementGroup
        • Overview
        • create
        • delete
        • get
        • list
        • listDisks
        • listOperations
        • update
      • DiskType
        • Overview
        • get
        • list
      • HostGroup
        • Overview
        • create
        • delete
        • get
        • list
        • listHosts
        • listInstances
        • listOperations
        • update
      • HostType
        • Overview
        • get
        • list
      • Image
        • Overview
        • create
        • delete
        • get
        • getLatestByFamily
        • list
        • listOperations
        • update
      • Instance
        • Overview
        • addOneToOneNat
        • attachDisk
        • create
        • delete
        • detachDisk
        • get
        • getSerialPortOutput
        • list
        • listOperations
        • removeOneToOneNat
        • restart
        • start
        • stop
        • update
        • updateMetadata
        • updateNetworkInterface
      • PlacementGroup
        • Overview
        • create
        • delete
        • get
        • list
        • listInstances
        • listOperations
        • update
      • Snapshot
        • Overview
        • create
        • delete
        • get
        • list
        • listOperations
        • update
      • Zone
        • Overview
        • get
        • list
      • Operation
        • Overview
        • get
      • InstanceGroup
        • Overview
        • createFromYaml
        • update
        • list
        • get
        • delete
        • start
        • stop
        • create
        • listAccessBindings
        • setAccessBindings
        • updateFromYaml
        • listLogRecords
        • listInstances
        • updateAccessBindings
        • listOperations
  • Questions and answers
    • General questions
    • Virtual machines
    • Disks and snapshots
    • Licensing
    • All questions on the same page
  1. Step-by-step instructions
  2. Creating instance groups
  3. Creating an instance group from Container Optimized Image

Creating an instance group from Container Optimized Image

    To run multiple instances of the service in Docker containers, you can create an instance group from a Container Optimized Image. In such groups, you can update Docker containers with VM metadata using the COI or Docker Compose specification.

    Alert

    When creating instance groups, keep the limits in mind. Not to disrupt the component Instance Groups, do not update or delete manually created resources: target group Network Load Balancer, VMs, and disks. To do this, change or delete the entire 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 create an instance group built on a Container Optimized Image:

    1. If you don't have the Yandex.Cloud command line interface yet, install and initialize it.

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

    3. View a description of the create instance group command in the CLI:

      $ yc compute instance-group create --help
      
    4. Check whether there are networks in the folder:

      $ yc vpc network list
      

      If there aren't any, create one.

    5. Create a YAML file with a name like specification.yaml.

    6. Select the latest version of the Container Optimized Image from the public images.

      To get the ID of the latest version of the Container Optimized Image image, run the command:

      $ yc compute image get-latest-from-family container-optimized-image --folder-id standard-images
      id: <image ID>
      folder_id: standard-images
      ...
      
    7. In the specification.yaml file you created, specify the following:

      • General information about the group:

        name: container-optimized-group
        service_account_id: aje3932acd8avp6edhbt
        description: "This instance group was created from YAML config."
        

        Keys:

        Key Value
        name A name for the instance group. The name must be unique within the folder. The name may contain lowercase Latin letters, numbers, and hyphens. The first character must be a letter. The last character can't be a hyphen. The maximum length of the name is 63 characters.
        service_account_id ID of the service account.
        description A description of the instance group.
      • Instance template:

        instance_template:
            platform_id: standard-v1
            resources_spec:
                memory: 2G
                cores: 2
            boot_disk_spec:
                mode: READ_WRITE
                disk_spec:
                    image_id: fd81a49qficqvt0dthu8
                    type_id: network-hdd
                    size: 32G
            network_interface_specs:
                - network_id: c64mknqgnd8avp6edhbt
                  primary_v4_address_spec: {}
            metadata:
                docker-container-declaration: |-
                    spec:
                        containers:
                            - name: nginx
                              image: cr.yandex/mirror/nginx:1.17.4-alpine
                              securityContext:
                                privileged: false
                              tty: false
                              stdin: false
        

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

        Name Example of a YAML file entry:
        Kilobyte 1073741824k
        Megabyte 1048576m
        Gigabyte 1024g
        Terabyte 1t

        Keys:

        Key Value
        platform_id Platform ID.
        memory Amount of memory (RAM).
        cores Number of processor cores (vCPUs).
        mode Disk access mode.
        - READ_ONLY: read-only access.
        - READ_WRITE: read/write access.
        image_id ID of the public Container Optimized Image.
        type_id Disk type.
        size Disk size.
        network_id The default-net ID.
        primary_v4_address_spec IPv4 specification. Only IPv4 is currently available. You can allow public access to group instances by specifying the IP version for the public IP address. For more information, see Template description in a YAML file.
        metadata Values to pass to the VM metadata.
        docker-container-declaration The key in the VM metadata that is used with the COI specification of the Docker container. In the metadata, you can use the Docker Compose specification. To do this, specify the docker-compose key instead of the docker-container-declaration key.
      • Policies:

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

        Keys:

        Key Value
        deploy_policy Deployment policy for instances in the group.
        scale_policy Scaling policy for instances in the group.
        allocation_policy Policy for allocating instances across zones and regions.

        Full code for the specification.yaml file:

        name: container-optimized-group
        service_account_id: aje3932acd8avp6edhbt
        description: "This instance group was created from YAML config."
        instance_template:
            service_account_id: aje3932acd8avp6edhbt # ID of the service account to access private Docker images.
            platform_id: standard-v1
            resources_spec:
                memory: 2G
                cores: 2
            boot_disk_spec:
                mode: READ_WRITE
                disk_spec:
                    image_id: fd81a49qficqvt0dthu8
                    type_id: network-hdd
                    size: 32G
            network_interface_specs:
                - network_id: c64mknqgnd8avp6edhbt
                  primary_v4_address_spec: {}
            metadata:
                docker-container-declaration: |-
                    spec:
                        containers:
                            - name: nginx
                              image: cr.yandex/mirror/nginx:1.17.4-alpine
                              securityContext:
                                privileged: false
                              tty: false
                              stdin: false
        deploy_policy:
            max_unavailable: 1
            max_expansion: 0
        scale_policy:
            fixed_scale:
                size: 3
        allocation_policy:
            zones:
                - zone_id: ru-central1-a
        

        Note

        To use in specification.yaml the Docker Compose specification, specify the docker-compose key instead of the docker-container-declaration key.

    8. Create an instance group in the default folder:

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

      This command creates a group of three similar instances with the following characteristics:

      • Named container-optimized-group.
      • From the latest version of the public Container Optimized Image.
      • With a running Docker container based on cr.yandex/mirror/nginx:1.17.4-alpine.
      • In the default-net network.
      • In the ru-central1-a availability zone.
      • With 2 vCPUs and 2 GB of RAM.
      • With a 32 GB network HDD.
    Language / Region
    Careers
    Privacy policy
    Terms of use
    Brandbook
    © 2021 Yandex.Cloud LLC