kubernetes/kops · error
failed to get instance metadata type
Error message
failed to get instance metadata type: %w
What it means
After loading AWS config, getMachineType queries the EC2 Instance Metadata Service at path 'instance-type' via the SDK's IMDS client. If that GetMetadata call fails (network, token, or endpoint error), nodeup wraps it with this message and cannot determine the machine type.
Solutions
- Verify metadata access from the node: curl -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/instance-type.
- Raise --http-put-response-hop-limit to 2+ if nodeup runs in a container.
- Re-enable the metadata endpoint if the instance was launched with metadata disabled.
- Retry after transient failure — IMDS token fetches can be throttled during fleet-wide scale-up events.
Defensive patterns
Strategy: retry
Validate before calling
curl -sf http://169.254.169.254/latest/meta-data/instance-type || echo 'IMDS unreachable pre-flight failure'
Try / catch
result, err := metadata.GetMetadata(ctx, &imds.GetMetadataInput{Path: "instance-type"})
if err != nil {
var rerr *retry.Error
if errors.As(err, &rerr) {
// throttled/transient: back off and retry with jitter
}
return fmt.Errorf("IMDS metadata query failed: %w", err)
} Prevention
- Allow link-local 169.254.169.254 in node network policies and firewalls.
- Configure IMDSv2 with adequate hop limit for containerized workloads.
- Use the SDK's default retryer and avoid hammering IMDS concurrently at boot.
- Keep metadata HttpEndpoint enabled on node launch templates.
When it happens
Trigger: imds.NewFromConfig(config).GetMetadata(ctx, {Path: "instance-type"}) returns an error: IMDS endpoint unreachable, IMDSv2 token request denied, metadata service disabled on the instance, or transient network failure.
Common situations: Nodeup running inside a container/network namespace that blocks 169.254.169.254; IMDSv2 with hop limit 1 while nodeup is one hop away; instance launched with metadata disabled (HttpEndpoint disabled); brief IMDS throttling at instance boot.
Related errors
- failed to get local-ipv4 address from ec2 metadata
- failed to load AWS config
- error querying ec2 metadata service (for region)
- error reading from AWS metadata service
- error reading instance-id from AWS metadata
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/45f9e5761a70223c.
Report an issue: GitHub.
Appendix: source
Thrown at upup/pkg/fi/nodeup/command.go:422
}
}
return nil
}
func getMachineType(ctx context.Context) (string, error) {
config, err := awsconfig.LoadDefaultConfig(ctx)
if err != nil {
return "", fmt.Errorf("failed to load AWS config: %w", err)
}
metadata := imds.NewFromConfig(config)
// Get the actual instance type by querying the EC2 instance metadata service.
result, err := metadata.GetMetadata(ctx, &imds.GetMetadataInput{
Path: "instance-type",
})
if err != nil {
return "", fmt.Errorf("failed to get instance metadata type: %w", err)
}
defer result.Content.Close()
instanceTypeName, err := io.ReadAll(result.Content)
if err != nil {
return "", fmt.Errorf("failed to read instance metadata response: %w", err)
}
return string(instanceTypeName), err
}
func completeWarmingLifecycleAction(ctx context.Context, cloud *awsup.Cloud, modelContext *model.NodeupModelContext) error {
asgName := modelContext.BootConfig.InstanceGroupName + "." + modelContext.NodeupConfig.ClusterName
hookName := "kops-warmpool"
hooks, err := cloud.DescribeLifecycleHooks(ctx, &autoscaling.DescribeLifecycleHooksInput{
AutoScalingGroupName: &asgName,
LifecycleHookNames: []string{hookName},
})
if err != nil {
return fmt.Errorf("failed to find lifecycle hook %q: %w", hookName, err)View on GitHub (pinned to 4c8573c808)