kubernetes/kops · error

error querying instance metadata: %s

Error message

error querying instance metadata: %s

What it means

The Azure node-identity client could not fetch instance metadata from IMDS during construction. This runs on the node at startup; failures are typically transient (metadata service not yet reachable) or caused by IMDS access restrictions.

Source

Thrown at pkg/nodeidentity/azure/client.go:43

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	compute "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute"
	"k8s.io/kops/upup/pkg/fi/cloudup/azure/azuremetadata"
)

// client is an Azure client.
type client struct {
	subscriptionID string
	vmClient       *compute.VirtualMachinesClient
	vmssClient     *compute.VirtualMachineScaleSetVMsClient
}

// newClient returns a new Client.
func newClient() (*client, error) {
	// nodeidentity.Identifier.New does not propagate a context; the IMDS HTTP client's own timeout
	// bounds this call.
	metadata, err := azuremetadata.QueryComputeInstanceMetadata(context.TODO())
	if err != nil {
		return nil, fmt.Errorf("error querying instance metadata: %s", err)
	}
	if metadata.SubscriptionID == "" {
		return nil, fmt.Errorf("empty subscription ID")
	}

	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		return nil, fmt.Errorf("creating identity: %w", err)
	}

	vmClient, err := compute.NewVirtualMachinesClient(metadata.SubscriptionID, cred, nil)
	if err != nil {
		return nil, fmt.Errorf("creating VMs client: %w", err)
	}

	vmssClient, err := compute.NewVirtualMachineScaleSetVMsClient(metadata.SubscriptionID, cred, nil)
	if err != nil {
		return nil, fmt.Errorf("creating VMSS VMs client: %w", err)

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Ensure the Azure IMDS endpoint (169.254.169.254) is reachable from the node
  2. Retry node startup/registration once metadata service is available
  3. Check that the VM's managed identity and network allow metadata queries
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at pkg/nodeidentity/azure/client.go:43 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/1002e1d1a36b268e. Report an issue: GitHub.