kubernetes/kops · error
building blockDeviceMappings for
Error message
building blockDeviceMappings for %q: %w
What it means
Returned by buildKarpenterEC2NodeClass when buildKarpenterBlockDeviceMappings(ig, rootDeviceName) fails to construct the block device mappings for the instance group. This reflects invalid volume configuration on the instance group relative to the resolved root device.
Solutions
- Check the wrapped error from buildKarpenterBlockDeviceMappings for the failing volume field
- Validate instance group rootVolume* settings (size, type) are sane and supported
- Remove or fix custom volumes entries incompatible with Karpenter mappings
- Align volume config with the root device name resolved from the image
Example fix
// before rootVolumeSize: -10 rootVolumeType: magic-ssd // after rootVolumeSize: 100 rootVolumeType: gp3
Defensive patterns
Strategy: validation
Validate before calling
// validate volume settings before rendering
if ig.Spec.MachineType == "" || ig.Spec.RootVolumeSize <= 0 {
return fmt.Errorf("instance group %q has invalid volume configuration", ig.Name)
} Try / catch
nc, err := tf.KarpenterEC2NodeClass(ig)
if err != nil {
return fmt.Errorf("blockDeviceMappings for %q failed: %w", ig.Name, err)
} Prevention
- Set sane rootVolumeSize (positive, within EBS limits) and a supported rootVolumeType
- Avoid custom volumes entries incompatible with Karpenter mappings
- Validate instance group storage specs during cluster spec validation
- Add unit tests for buildKarpenterBlockDeviceMappings edge cases
When it happens
Trigger: Instance group storage/volume spec values are invalid for building Karpenter blockDeviceMappings — e.g. nil/invalid rootVolume settings, unsupported volume type, or size/format values that cannot be translated.
Common situations: rootVolumeSize/rootVolumeType set to values unsupported by Karpenter mapping; volumes list with malformed entries; mixing volume settings incompatible with the image's root device.
Related errors
- adding encryptionconfig secret
- building amiSelectorTerms for
- building instance profile for
- building tags for
- could not determine any subnets for InstanceGroup
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/849453b47cacb949.
Report an issue: GitHub.
Appendix: source
Thrown at upup/pkg/fi/cloudup/template_functions_karpenter.go:244
if err != nil {
return nil, fmt.Errorf("building tags for %q: %w", ig.Name, err)
}
tags = karpenterEC2NodeClassTags(tags)
associatePublicIP, err := tf.karpenterAssociatePublicIP(ig)
if err != nil {
return nil, err
}
userData, err := tf.managedFileContents("nodeupscript-" + ig.Name)
if err != nil {
return nil, fmt.Errorf("reading userData for %q: %w", ig.Name, err)
}
rootDeviceName, err := tf.karpenterRootDeviceName(ig.Spec.Image)
if err != nil {
return nil, fmt.Errorf("resolving root device for %q: %w", ig.Name, err)
}
blockDeviceMappings, err := buildKarpenterBlockDeviceMappings(ig, rootDeviceName)
if err != nil {
return nil, fmt.Errorf("building blockDeviceMappings for %q: %w", ig.Name, err)
}
subnetTerms := []karpenterSelectorTerm{
{
Tags: map[string]string{
"KubernetesCluster": tf.ClusterName(),
"kops.k8s.io/instance-group/" + ig.Name: "true",
},
},
}
securityGroupTerms := []karpenterSelectorTerm{}
if ig.Spec.SecurityGroupOverride != nil {
securityGroupTerms = append(securityGroupTerms, karpenterSelectorTerm{ID: fi.ValueOf(ig.Spec.SecurityGroupOverride)})
} else {
securityGroupTerms = append(securityGroupTerms, karpenterSelectorTerm{
Tags: map[string]string{
"KubernetesCluster": tf.ClusterName(),View on GitHub (pinned to 4c8573c808)