kubernetes/kops · error

Cannot apply changes to InstanceTemplate: %v

Error message

Cannot apply changes to InstanceTemplate: %v

What it means

Returned from InstanceTemplate.RenderGCE when the template already exists (a != nil). Instance templates are immutable in this task — no update path exists, so any non-empty diff is rejected. (Normally instance-template drift is handled by generating a new template name and rolling the IG.)

Source

Thrown at upup/pkg/fi/cloudup/gcetasks/instancetemplate.go:544

	}

	if a == nil {
		klog.V(4).Infof("Creating InstanceTemplate %v", i)

		name := fi.ValueOf(e.NamePrefix) + "-" + strconv.FormatInt(time.Now().Unix(), 10)
		e.ID = &name
		i.Name = name

		op, err := t.Cloud.Compute().InstanceTemplates().Insert(t.Cloud.Project(), i)
		if err != nil {
			return fmt.Errorf("error creating InstanceTemplate: %v", err)
		}

		if err := t.Cloud.WaitForOp(op); err != nil {
			return fmt.Errorf("error creating InstanceTemplate: %v", err)
		}
	} else {
		return fmt.Errorf("Cannot apply changes to InstanceTemplate: %v", changes)
	}

	return nil
}

type terraformInstanceTemplate struct {
	Lifecycle             *terraform.Lifecycle                     `cty:"lifecycle"`
	NamePrefix            string                                   `cty:"name_prefix"`
	CanIPForward          bool                                     `cty:"can_ip_forward"`
	MachineType           string                                   `cty:"machine_type"`
	ServiceAccounts       []*terraformTemplateServiceAccount       `cty:"service_account"`
	Scheduling            *terraformScheduling                     `cty:"scheduling"`
	Disks                 []*terraformInstanceTemplateAttachedDisk `cty:"disk"`
	Labels                map[string]string                        `cty:"labels"`
	NetworkInterfaces     []*terraformNetworkInterface             `cty:"network_interface"`
	Metadata              map[string]*terraformWriter.Literal      `cty:"metadata"`
	MetadataStartupScript *terraformWriter.Literal                 `cty:"metadata_startup_script"`
	Tags                  []string                                 `cty:"tags"`

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Inspect the printed diff to see what drifted from the managed template
  2. Trigger a rolling update so a new template is created and instances are replaced
  3. Remove manual changes to the instance template or align the spec with reality
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at upup/pkg/fi/cloudup/gcetasks/instancetemplate.go:544 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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