kubernetes/kubernetes · error
unsupported container resource : %v
Error message
unsupported container resource : %v
What it means
Returned by ExtractContainerResourceValue when the ResourceFieldSelector.Resource field doesn't match any of the supported resource selector paths. Supported values are limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory, requests.ephemeral-storage, and the hugepages variants (requests.hugepages-<size>, limits.hugepages-<size>). Any other value (e.g., limits.nvidia.com/gpu, requests.storage, a typo) triggers this error. This function is used by the kubelet and kubectl for Downward API resource field references.
Source
Thrown at pkg/api/v1/resource/helpers.go:142
return convertResourceMemoryToString(container.Resources.Requests.Memory(), divisor)
case "requests.ephemeral-storage":
return convertResourceEphemeralStorageToString(container.Resources.Requests.StorageEphemeral(), divisor)
}
// handle extended standard resources with dynamic names
// example: requests.hugepages-<pageSize> or limits.hugepages-<pageSize>
if strings.HasPrefix(fs.Resource, "requests.") {
resourceName := v1.ResourceName(strings.TrimPrefix(fs.Resource, "requests."))
if IsHugePageResourceName(resourceName) {
return convertResourceHugePagesToString(container.Resources.Requests.Name(resourceName, resource.BinarySI), divisor)
}
}
if strings.HasPrefix(fs.Resource, "limits.") {
resourceName := v1.ResourceName(strings.TrimPrefix(fs.Resource, "limits."))
if IsHugePageResourceName(resourceName) {
return convertResourceHugePagesToString(container.Resources.Limits.Name(resourceName, resource.BinarySI), divisor)
}
}
return "", fmt.Errorf("unsupported container resource : %v", fs.Resource)
}
// convertResourceCPUToString converts cpu value to the format of divisor and returns
// ceiling of the value.
func convertResourceCPUToString(cpu *resource.Quantity, divisor resource.Quantity) (string, error) {
c := int64(math.Ceil(float64(cpu.MilliValue()) / float64(divisor.MilliValue())))
return strconv.FormatInt(c, 10), nil
}
// convertResourceMemoryToString converts memory value to the format of divisor and returns
// ceiling of the value.
func convertResourceMemoryToString(memory *resource.Quantity, divisor resource.Quantity) (string, error) {
m := int64(math.Ceil(float64(memory.Value()) / float64(divisor.Value())))
return strconv.FormatInt(m, 10), nil
}
// convertResourceHugePagesToString converts hugepages value to the format of divisor and returns
// ceiling of the value.View on GitHub (pinned to 94c1367642)
Solutions
- Check the error message for the exact unsupported resource value.
- Use only supported resource selectors: limits.cpu, requests.cpu, limits.memory, requests.memory, limits.ephemeral-storage, requests.ephemeral-storage, or limits.hugepages-<size>/requests.hugepages-<size>.
- If you need to expose a non-standard resource (GPU, extended resource), use a different mechanism — the Downward API resourceFieldRef does not support extended resources.
- Fix typos in the resource path (e.g., 'limit.cpu' -> 'limits.cpu').
Example fix
// before: unsupported resource in Downward API
env:
- name: GPU_LIMIT
valueFrom:
resourceFieldRef:
containerName: my-container
resource: limits.nvidia.com/gpu # not supported
// after: use a supported resource
env:
- name: CPU_LIMIT
valueFrom:
resourceFieldRef:
containerName: my-container
resource: limits.cpu Defensive patterns
Strategy: validation
Validate before calling
// Validate the resource field selector before using it in a Downward API reference
var supportedResourceSelectors = map[string]bool{
"limits.cpu": true, "requests.cpu": true,
"limits.memory": true, "requests.memory": true,
"limits.ephemeral-storage": true, "requests.ephemeral-storage": true,
}
func isSupportedResourceSelector(resource string) bool {
if supportedResourceSelectors[resource] {
return true
}
if strings.HasPrefix(resource, "requests.hugepages-") || strings.HasPrefix(resource, "limits.hugepages-") {
return true
}
return false
}
// Usage:
if !isSupportedResourceSelector(fs.Resource) {
return fmt.Errorf("unsupported container resource: %s", fs.Resource)
} Try / catch
value, err := resource.ExtractContainerResourceValue(fs, container)
if err != nil {
if strings.Contains(err.Error(), "unsupported container resource") {
klog.Warningf("unsupported resource field selector %q — only cpu/memory/ephemeral-storage/hugepages are supported", fs.Resource)
}
return "", err
} Prevention
- Only use limits.cpu, requests.cpu, limits.memory, requests.memory, limits.ephemeral-storage, requests.ephemeral-storage, or hugepages-* variants in resourceFieldRef.resource.
- Double-check spelling: 'limits' not 'limit', 'requests' not 'request'.
- The Downward API does not support extended resources (GPU, FPGA, etc.) — use a different mechanism for those.
- Validate the resource selector string before submitting pod specs.
When it happens
Trigger: A pod spec uses a Downward API volume item or env var valueFrom.resourceFieldRef with a Resource value that doesn't match any of the known selector paths. The switch statement at line 114-127 exhausts all cases, the hugepages prefix checks at lines 130-140 don't match, and the error is returned. This typically happens when someone references a resource name that isn't a standard CPU/memory/ephemeral-storage/hugepages resource (e.g., an extended resource like GPU, or a typo like 'limit.cpu' instead of 'limits.cpu').
Common situations: Trying to expose a GPU or extended resource limit via the Downward API (not supported — only CPU/memory/ephemeral-storage/hugepages are exposed). Typographical errors in the resource path (e.g., 'limit.cpu' vs 'limits.cpu', 'request.memory' vs 'requests.memory'). Using a resource name without the limits./requests. prefix.
Related errors
- field label not supported for %s: %s
- field label not supported for %s: %s
- field label not supported for %s: %s
- container %s not found
- field label not supported: %s
AI-assisted analysis of kubernetes/kubernetes@94c1367642 (2026-08-08).
Data as JSON: /api/errors/80fdca810eaeb4df.
Report an issue: GitHub.