kubernetes/kops · error

instance group must have the same min and max size in Azure,

Error message

instance group must have the same min and max size in Azure, but got %d and %d

What it means

Azure VM ScaleSets provision a fixed-size group, so getCapacity requires the InstanceGroup's computed minSize and maxSize to be equal. When the effective min and max differ (after defaults are applied), it returns this error instead of building the scale set.

Source

Thrown at pkg/model/azuremodel/vmscaleset.go:199

	return t, nil
}

func getCapacity(spec *kops.InstanceGroupSpec) (*int64, error) {
	// Follow the convention that all other CSPs have.
	minSize := int32(1)
	maxSize := int32(1)
	if spec.MinSize != nil {
		minSize = fi.ValueOf(spec.MinSize)
	} else if spec.Role.HasNode() {
		minSize = 2
	}
	if spec.MaxSize != nil {
		maxSize = *spec.MaxSize
	} else if spec.Role.HasNode() {
		maxSize = 2
	}
	if minSize != maxSize {
		return nil, fmt.Errorf("instance group must have the same min and max size in Azure, but got %d and %d", minSize, maxSize)
	}
	return new(int64(minSize)), nil
}

func getStorageProfile(spec *kops.InstanceGroupSpec) (*compute.VirtualMachineScaleSetStorageProfile, error) {
	var volumeSize int32
	if spec.RootVolume != nil && spec.RootVolume.Size != nil {
		volumeSize = *spec.RootVolume.Size
	} else {
		var err error
		volumeSize, err = defaults.DefaultInstanceGroupVolumeSize(spec.Role)
		if err != nil {
			return nil, err
		}
	}

	var storageAccountType compute.StorageAccountTypes
	if spec.RootVolume != nil && spec.RootVolume.Type != nil {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Set spec.minSize and spec.maxSize to the same value in the InstanceGroup.
  2. Remove both fields entirely so both fall back to the same defaults.
  3. For elasticity on Azure, manage scaling via external autoscaler/cluster-autoscaler rather than differing min/max in the kops spec.

Example fix

// before
minSize: 1
maxSize: 5
// after
minSize: 3
maxSize: 3
Defensive patterns

Strategy: validation

Validate before calling

if ig.Spec.MinSize != nil && ig.Spec.MaxSize != nil && *ig.Spec.MinSize != *ig.Spec.MaxSize {
  return fmt.Errorf("azure instance group %q requires minSize == maxSize", ig.Name)
}

Prevention

When it happens

Trigger: Setting spec.minSize and spec.maxSize to different values on an Azure InstanceGroup, e.g. minSize: 1, maxSize: 5, then running `kops update cluster`.

Common situations: Pasting AWS-style autoscaling min/max configs into Azure clusters; relying on defaults where one size is set and the other falls back to a default (2 for node roles), causing a mismatch.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/0157220dba66441a. Report an issue: GitHub.