Skip to content

The InstanceGroup resource

The InstanceGroup resource represents a group of similar machines typically provisioned in the same availability zone. On AWS, instance groups map directly to an autoscaling group.

The complete list of keys can be found at the InstanceGroup reference page.

You can also find concrete use cases for the configurations on the Instance Group operations page

On this page, we will expand on the more important configuration keys.


If you need to add tags on auto scaling groups or instances (propagate ASG tags), you can add it in the instance group specs with cloudLabels. Cloud Labels defined at the cluster spec level will also be inherited.

    billing: infra
    environment: dev


Autoscaling groups automatically include multiple scaling processes that keep our ASGs healthy. In some cases, you may want to disable certain scaling activities.

An example of this is if you are running multiple AZs in an ASG while using a Kubernetes Autoscaler. The autoscaler will remove specific instances that are not being used. In some cases, the AZRebalance process will rescale the ASG without warning.

  - AZRebalance


Autoscaling groups may scale up or down automatically to balance types of instances, regions, etc. Instance protection prevents the ASG from being scaled in.

  instanceProtection: true


By default, both IMDSv1 and IMDSv2 are enabled. The instance metadata service can be configured to allow only IMDSv2.

    httpPutResponseHopLimit: 1
    httpTokens: required


Instance groups can be linked to up to 10 load balancers. When attached, any instance launched will automatically register itself to the load balancer. For example, if you can create an instance group dedicated to running an ingress controller exposed on a NodePort, you can manually create a load balancer and link it to the instance group. Traffic to the load balancer will now automatically go to one of the nodes.

You can specify either loadBalancerName to link the instance group to an AWS Classic ELB or you can specify targetGroupArn to link the instance group to a target group, which are used by Application load balancers and Network load balancers.

kind: InstanceGroup
  name: ingress
  machineType: m4.large
  maxSize: 2
  minSize: 2
  role: Node
  - targetGroupArn: arn:aws:elasticloadbalancing:eu-west-1:123456789012:targetgroup/my-ingress-target-group/0123456789abcdef
  - loadBalancerName: my-elb-classic-load-balancer


Detailed monitoring will cause the monitoring data to be available every 1 minute instead of every 5 minutes. Enabling Detailed Monitoring. In production environments you may want to consider to enable detailed monitoring for quicker troubleshooting.

Note: that enabling detailed monitoring is a subject for charge

  detailedInstanceMonitoring: true


kOps utilizes cloud-init to initialize and setup a host at boot time. However in certain cases you may already be leveraging certain features of cloud-init in your infrastructure and would like to continue doing so. More information on cloud-init can be found here

Additional user-data can be passed to the host provisioning by setting the additionalUserData field. A list of valid user-data content-types can be found here


  - name:
    type: text/x-shellscript
    content: |
      echo "Hello World.  The time is now $(date -R)!" | tee /root/output.txt
  - name: local_repo.txt
    type: text/cloud-config
    content: |
          - arches: [default]
            uri: http://local-mirror.mydomain
              - http://local-mirror.mydomain


Kops 1.19

Compresses parts of the user-data to save space and help with the size limit in certain clouds. Currently only the Specs in will be compressed.

  compressUserData: true


Kops 1.17

To add custom kernel runtime parameters to your instance group, specify the sysctlParameters field as an array of strings. Each string must take the form of variable=value the way it would appear in sysctl.conf (see also sysctl(8) manpage).

Unlike a simple file asset, specifying kernel runtime parameters in this manner would correctly invoke sysctl --system automatically for you to apply said parameters.

For example:

kind: InstanceGroup
  name: nodes
    - fs.pipe-user-pages-soft=524288
    - net.ipv4.tcp_keepalive_time=200

which would end up in a drop-in file on nodes of the instance group in question.

mixedInstancesPolicy (AWS Only)

A Mixed Instances Policy utilizing EC2 Spot and the capacity-optimized allocation strategy allows an EC2 Autoscaling Group to select the instance types with the highest capacity. This reduces the chance of a spot interruption on your instance group.

Instance groups with a mixedInstancesPolicy can be generated with the kops toolbox instance-selector command. The instance-selector accepts user supplied resource parameters like vcpus, memory, and much more to dynamically select instance types that match your criteria.

kops toolbox instance-selector --vcpus 4 --flexible --usage-class spot --instance-group-name spotgroup
kind: InstanceGroup
  labels: spot.k8s.local
  name: spotgroup
  image: 099720109477/ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20200528
  machineType: c3.xlarge
  maxSize: 15
  minSize: 2
    - c3.xlarge
    - c4.xlarge
    - c5.xlarge
    - c5a.xlarge
    onDemandAboveBase: 0
    onDemandBase: 0
    spotAllocationStrategy: capacity-optimized
  nodeLabels: spotgroup
  role: Node
  - us-east-1a
  - us-east-1b
  - us-east-1c


Instances is a list of instance types which we are willing to run in the EC2 Auto Scaling group.


Indicates how to allocate instance types to fulfill On-Demand capacity


OnDemandBase is the minimum amount of the Auto Scaling group's capacity that must be fulfilled by On-Demand Instances. This base portion is provisioned first as your group scales.


OnDemandAboveBase controls the percentages of On-Demand Instances and Spot Instances for your additional capacity beyond OnDemandBase. The range is 0–100. The default value is 100. If you leave this parameter set to 100, the percentages are 100% for On-Demand Instances and 0% for Spot Instances.


SpotAllocationStrategy Indicates how to allocate instances across Spot Instance pools.

If the allocation strategy is lowest-price, the Auto Scaling group launches instances using the Spot pools with the lowest price, and evenly allocates your instances across the number of Spot pools that you specify in spotInstancePools. If the allocation strategy is capacity-optimized, the Auto Scaling group launches instances using Spot pools that are optimally chosen based on the available Spot capacity.


Used only when the Spot allocation strategy is lowest-price. The number of Spot Instance pools across which to allocate your Spot Instances. The Spot pools are determined from the different instance types in the Overrides array of LaunchTemplate. Default if not set is 2.