{"record":{"id":"4be002ab4be8de03","repo":"kubernetes/kops","slug":"ig-name-not-set-on-instance-template-s","errorCode":null,"errorMessage":"ig name not set on instance template %s","messagePattern":"ig name not set on instance template (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/nodeidentity/gce/identify.go","lineNumber":177,"sourceCode":"\t\t// We now double check that the instance is indeed managed by the MIG\n\t\t// this can't be spoofed without GCE API access\n\t\tmigMember, err := i.getManagedInstance(ctx, mig, instance.Id)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif migMember.Version == nil {\n\t\t\treturn nil, fmt.Errorf(\"instance %s did not have Version set\", instance.Name)\n\t\t}\n\n\t\tinstanceTemplate, err := i.getInstanceTemplate(lastComponent(migMember.Version.InstanceTemplate))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tigName = getMetadataValue(instanceTemplate.Properties.Metadata, MetadataKeyInstanceGroupName)\n\t\tif igName == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"ig name not set on instance template %s\", instanceTemplate.Name)\n\t\t}\n\t}\n\n\tinfo := &nodeidentity.Info{}\n\t// info.InstanceID TODO: InstanceID is only used by the provider?\n\n\ttagToRole := make(map[string]kops.InstanceGroupRole)\n\tfor _, role := range kops.AllInstanceGroupRoles {\n\t\ttag := gce.TagForRole(i.clusterName, role)\n\t\ttagToRole[tag] = role\n\t}\n\n\tlabels := make(map[string]string)\n\tfor _, tag := range instance.Tags.Items {\n\t\trole, found := tagToRole[tag]\n\t\tif found {\n\t\t\tswitch role {\n\t\t\tcase kops.InstanceGroupRoleControlPlane:","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/nodeidentity/gce/identify.go#L159-L195","documentation":"The final step of the legacy path reads the instance-group name from the resolved instance template's metadata (MetadataKeyInstanceGroupName). If the template exists but lacks that metadata key, kops cannot map the instance back to its instance group, so identification fails. This indicates the template was not created by kops (or was edited).","triggerScenarios":"migMember.Version -> instanceTemplate fetched successfully, but instanceTemplate.Properties.Metadata has no item whose key equals MetadataKeyInstanceGroupName — e.g. template created manually or by another tool.","commonSituations":"Custom/foreign instance templates attached to kops-managed MIGs; templates edited via console stripping kops metadata; kops versions mismatch where a newer/older template layout is present; manually rolled MIGs to hand-built templates.","solutions":["Re-add the kops metadata to the template, or better: re-roll the MIG to the kops-generated instance template (kops rolling-update cluster --cloud-init).","Verify the template with gcloud compute instance-templates describe <tmpl> --format='yaml(properties.metadata)' and confirm the instance-group-name key exists.","Ensure the cluster was created/updated with kops so templates carry kops metadata; run kops update cluster and rolling-update.","If using CAPI, confirm the machine template is generated by CAPG with the expected metadata."],"exampleFix":"// before — foreign template without kops metadata\nigName = getMetadataValue(instanceTemplate.Properties.Metadata, MetadataKeyInstanceGroupName) // \"\"\n// after — ensure MIG uses kops template\n// gcloud compute instance-groups managed set-instance-template <mig> \\\n//   --zone <zone> --instance-template <kops-generated-template>\nigName = getMetadataValue(instanceTemplate.Properties.Metadata, MetadataKeyInstanceGroupName)","handlingStrategy":"validation","validationCode":"tmpl, err := getInstanceTemplate(lastComponent(migMember.Version.InstanceTemplate))\nif err == nil && getMetadataValue(tmpl.Properties.Metadata, MetadataKeyInstanceGroupName) == \"\" {\n    return fmt.Errorf(\"template %s lacks %s metadata; not a kops template\", tmpl.Name, MetadataKeyInstanceGroupName)\n}","typeGuard":"func isKopsTemplate(t *compute.InstanceTemplate) bool {\n    return t != nil && t.Properties != nil &&\n        getMetadataValue(t.Properties.Metadata, MetadataKeyInstanceGroupName) != \"\"\n}","tryCatchPattern":"info, err := identifier.IdentifyNode(ctx, node)\nif err != nil && strings.Contains(err.Error(), \"ig name not set on instance template\") {\n    // template not kops-generated: flag for kops update / manual fix\n    return fmt.Errorf(\"node %s uses non-kops template; run kops update cluster\", node.Name)\n}","preventionTips":["Never roll MIGs onto hand-built instance templates in kops clusters.","Let kops generate templates via kops update cluster.","Verify templates carry the instance-group-name metadata before use.","Diff templates after console edits to ensure kops metadata survives."],"tags":["gce","mig","node-identity","instance-template","metadata"],"backgroundTag":"missing-template-metadata","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}