kubernetes/kops · error

unable to resolve IP for instance: %v

Error message

unable to resolve IP for instance: %v

What it means

mapToGCE resolves the instance's static IP by invoking the caller-provided ipAddressResolver on e.IPAddress (typically finding a GCE Address task). If resolution fails — the address resource can't be looked up or an error occurred while finding it — this error wraps the cause. A nil addr with no error is handled separately as 'instance IP address has not yet been created'.

Source

Thrown at upup/pkg/fi/cloudup/gcetasks/instance.go:241

	if e.Tags != nil {
		tags = &compute.Tags{
			Items: e.Tags,
		}
	}

	var networkInterfaces []*compute.NetworkInterface
	{
		networkInterface := &compute.NetworkInterface{
			AccessConfigs: []*compute.AccessConfig{{
				Type: "ONE_TO_ONE_NAT",
			}},
			Network: e.Network.URL(project),
		}

		if e.IPAddress != nil {
			addr, err := ipAddressResolver(e.IPAddress)
			if err != nil {
				return nil, fmt.Errorf("unable to resolve IP for instance: %v", err)
			}
			if addr == nil {
				return nil, fmt.Errorf("instance IP address has not yet been created")
			}
			networkInterface.AccessConfigs[0].NatIP = *addr
		}
		if e.Subnet != nil {
			networkInterface.Subnetwork = *e.Subnet.Name
		}
		if e.StackType != nil {
			networkInterface.StackType = *e.StackType
		}
		networkInterfaces = append(networkInterfaces, networkInterface)
	}

	var serviceAccounts []*compute.ServiceAccount
	if e.ServiceAccount != nil {
		if e.Scopes != nil {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Verify the referenced address name matches an existing GCE static address in the correct region: `gcloud compute addresses list`
  2. Fix or remove the ipAddress field on the instance spec so the instance uses an ephemeral IP
  3. Ensure the Address task is still defined in the cluster spec and renders successfully
  4. Retry `kops update cluster` after correcting the address reference

Example fix

// before (instance spec)
ipAddress: old-removed-address
// after
ipAddress: my-reserved-ip   # matching an existing Address task in the same region
# or remove the ipAddress field entirely for an ephemeral IP
Defensive patterns

Strategy: validation

Validate before calling

// Ensure the referenced address exists (in the right region) before rendering the instance
func assertAddressExists(svc *compute.Service, project, region, name string) error {
	_, err := svc.Addresses.Get(project, region, name).Do()
	return err
}

Type guard

func resolvableAddress(e *Instance, resolver func(*Address) (*string, error)) bool {
	if e.IPAddress == nil { return true }
	addr, err := resolver(e.IPAddress)
	return err == nil && addr != nil
}

Try / catch

addr, err := ipAddressResolver(e.IPAddress)
if err != nil {
	return nil, fmt.Errorf("unable to resolve IP for instance: %v", err)
}
if addr == nil {
	return nil, fmt.Errorf("instance IP address has not yet been created")
}

Prevention

When it happens

Trigger: ipAddressResolver(e.IPAddress) returns an error during RenderGCE or RenderTerraform: the referenced Address task failed to render, the address name doesn't exist in the project/region, or the address lookup API call failed.

Common situations: Instance spec references an ipAddress whose Address task was removed or renamed; reserved address exists in a different region; dependency ordering so the Address task errors out first; typo in the address name.

Related errors


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