kubernetes/kops · error

error creating InstanceTemplate

Error message

error creating InstanceTemplate: %v

What it means

Wrapped error from InstanceTemplate.RenderGCE when the synchronous InstanceTemplates.Insert call fails while creating a new template (a == nil). GCE rejected the create — typical causes are invalid machine type, bad metadata/service-account fields, or permissions/quota.

Solutions

  1. Read the wrapped API error to find the rejected field
  2. Verify machine type, service account, and image reference in the template spec
  3. Fix permissions/quota and re-run the apply
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at upup/pkg/fi/cloudup/gcetasks/instancetemplate.go:537 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/85d9551316ae459d. Report an issue: GitHub.

Appendix: source

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

func (_ *InstanceTemplate) RenderGCE(t *gce.GCEAPITarget, a, e, changes *InstanceTemplate) error {
	project := t.Cloud.Project()
	region := t.Cloud.Region()

	i, err := e.mapToGCE(project, region)
	if err != nil {
		return err
	}

	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"`

View on GitHub (pinned to 4c8573c808)