Files
troubleshoot/examples/preflight/node-resources.yaml
Nicholas Fernandes 40bb2e3a2a Fix incorrect field names in nodeResources example files (#1917)
The nodeResources filter examples incorrectly used `allocatableMemory`
instead of `memoryAllocatable`. This causes YAML parsing to silently
ignore the field, resulting in empty filter values and unexpected
analyzer behavior.

Changed in 3 files (5 instances total):
- examples/preflight/node-resources.yaml (3 instances)
- examples/preflight/e2e.yaml (1 instance)
- examples/support-bundle/e2e.yaml (1 instance)

The correct field names according to pkg/apis/troubleshoot/v1beta2/analyzer_shared.go
are:
- memoryAllocatable (not allocatableMemory)
- cpuAllocatable (not allocatableCPU)
- memoryCapacity (not capacityMemory)
- cpuCapacity (not capacityCPU)

This bug caused users copying from these examples to experience false
failures in preflight checks, as documented in the bug report where
a GKE cluster with 85Gi memory failed a check requiring only 8Gi.
2025-11-06 15:30:27 -06:00

84 lines
3.2 KiB
YAML

apiVersion: troubleshoot.sh/v1beta2
kind: Preflight
metadata:
name: sample
spec:
analyzers:
- nodeResources:
checkName: Must have at least 3 nodes in the cluster
outcomes:
- fail:
when: "< 3"
message: This application requires at least 3 nodes
- warn:
when: "< 5"
message: This application recommends at last 5 nodes.
- pass:
message: This cluster has enough nodes.
- nodeResources:
checkName: Must have 3 nodes with at least 6 cores each
filters:
cpuCapacity: "6"
outcomes:
- fail:
when: "count() < 3"
message: This application requires at least 3 nodes with 6 cores each
- pass:
message: This cluster has enough nodes with enough cores
- nodeResources:
checkName: Must have 1 node with 16 GB (available) memory and 10 cores (on a single node)
filters:
memoryAllocatable: 16Gi
cpuCapacity: "10"
outcomes:
- fail:
when: "< 1"
message: This application requires at least 1 node with 16GB available memory
- pass:
message: This cluster has a node with enough memory.
- nodeResources:
checkName: Must have 1 node with 16 GB (available) memory and 4 cores of amd64 arch (on a single node)
filters:
memoryAllocatable: 16Gi
cpuArchitecture: amd64
cpuCapacity: "4"
outcomes:
- fail:
when: "< 1"
message: This application requires at least 1 node with amd64 arch and 16GB available memory
- pass:
message: This cluster has a node with the correct architecture and enough memory.
- nodeResources:
checkName: Must have 1 manager node with 16 GB (available) memory and 4 cores of amd64 arch
filters:
selector:
matchLabel:
node-role.kubernetes.io/master: ""
memoryAllocatable: 16Gi
cpuArchitecture: amd64
cpuCapacity: "6"
outcomes:
- fail:
when: "< 1"
message: This application requires at least 1 manager node with amd64 arch, 16GB available memory, and the label `node-role.kubernetes.io/master=""`
- pass:
message: This cluster has a node with the correct architecture and enough memory.
- nodeResources:
checkName: There must be a total of at least 32Gi of memory on all nodes
outcomes:
- fail:
when: "sum(memoryCapacity) < 32Gi"
message: This application requires that 32Gi or more memory be available to the cluster
- pass:
message: This cluster has sufficient memory
- nodeResources:
checkName: There must be a total of at least 32Gi of memory on amd64 nodes
filters:
cpuArchitecture: amd64
outcomes:
- fail:
when: "sum(memoryCapacity) < 32Gi"
message: This application requires that 32Gi or more memory on amd64 nodes be available to the cluster
- pass:
message: This cluster has sufficient memory