kubernetes/kops · error

error finding node name for instance: %v

Error message

error finding node name for instance: %v

What it means

After an instance is located in a cloud group, in API (non --cloudonly) mode kops requires the matching Kubernetes Node object to drain/cordon it. This error is returned when the cloud instance member was found but its Node field is nil — i.e. the cloud instance has no corresponding Node registered in the k8s API.

Source

Thrown at cmd/kops/delete_instance.go:233

	if err != nil {
		return err
	}

	cloudMember := findDeletionNode(groups, options)

	if cloudMember == nil {
		return fmt.Errorf("could not find instance %v", options.InstanceID)
	}

	if options.CloudOnly {
		fmt.Fprintf(out, "Instance %v found for deletion\n", cloudMember.ID)
	} else {
		if cloudMember.Node != nil {
			fmt.Fprintf(out, "Instance %v (%v) found for deletion\n", cloudMember.ID, cloudMember.Node.Name)
		} else {
			fmt.Fprintf(os.Stderr, "Instance is not a member of the cluster\n")
			fmt.Fprintf(os.Stderr, "Use --cloudonly to do a deletion without confirming progress with the k8s API\n\n")
			return fmt.Errorf("error finding node name for instance: %v", cloudMember.ID)
		}
	}

	if !options.Yes {
		fmt.Fprintf(out, "\nMust specify --yes to delete instance\n")
		return nil
	}

	d := &instancegroups.RollingUpdateCluster{
		Clientset:         clientSet,
		Cluster:           cluster,
		MasterInterval:    0,
		NodeInterval:      0,
		BastionInterval:   0,
		Interactive:       false,
		Force:             true,
		Cloud:             cloud,
		K8sClient:         k8sClient,

View on GitHub (pinned to 4c8573c808)

Solutions

  1. If you are sure the instance should be removed without k8s coordination, re-run with --cloudonly --yes.
  2. Check whether the Node exists: `kubectl get nodes` and compare node names against the instance ID/private DNS.
  3. If the Node object was deleted but the instance still runs, either recreate the Node object (restart kubelet) or just terminate the instance directly in the cloud console.
  4. Investigate why the kubelet is not registering: check node bootstrap, IAM instance profile, and CNI/networking on the instance.
  5. Confirm the instance belongs to this cluster (right VPC/account/cluster tags) — a foreign instance will never have a Node here.

Example fix

// before
kops delete instance --name mycluster.example.com i-0abc123
// error: error finding node name for instance: i-0abc123
// after (cloud-only deletion, skipping k8s API confirmation)
kops delete instance --name mycluster.example.com i-0abc123 --cloudonly --yes
Defensive patterns

Strategy: validation

Validate before calling

// before deleting in API mode, confirm the node is registered:
nodes, err := getNodes(ctx, k8sClient, true)
if err != nil {
    return err
}
found := false
for _, n := range nodes {
    if n.Name == options.InstanceID || providerIDMatches(n, options.InstanceID) {
        found = true
        break
    }
}
if !found {
    return fmt.Errorf("instance %s has no registered Node; use --cloudonly or fix kubelet registration", options.InstanceID)
}

Type guard

func hasNode(m *cloudinstances.CloudInstance) bool { return m != nil && m.Node != nil }

Try / catch

if cloudMember.Node == nil {
    if !options.CloudOnly {
        fmt.Fprintf(os.Stderr, "Instance %s has no k8s Node; retry with --cloudonly to delete without API confirmation\n", cloudMember.ID)
        return fmt.Errorf("error finding node name for instance: %v", cloudMember.ID)
    }
}

Prevention

When it happens

Trigger: `kops delete instance` (without --cloudonly) on an instance ID that exists in the cloud ASG but whose Node is absent from the cluster: the kubelet never registered, the Node was already deleted from the API, or the instance ID matches a cloud member only via ID and no Node.Name comparison succeeded.

Common situations: Instance booted but kubelet failed to start/join (bootstrap or networking problem); node was removed via `kubectl delete node` earlier but the EC2 instance still runs; long-stopped instance whose Node object was garbage-collected; instance group instances that are control-plane/masters never register as deletable nodes; API server reachable (nodes were listed successfully) so --cloudonly is the intended escape hatch.

Related errors


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