Node

2 min read

Read a Node: readiness, allocatable CPU and memory, conditions, taints, and where it is (zone, region, instance type, from the well-known topology labels); and which node a pod is scheduled on.

Reference

FunctionDescription
nodeAllocatableCPUReturns status.allocatable.cpu.
nodeAllocatableMemoryReturns status.allocatable.memory.
nodeConditionReturns the status string of the named node condition, or "" when absent — common types are Ready, MemoryPressure, and DiskPressure.
nodeInstanceTypeReturns the node’s instance type (label node.kubernetes.io/instance-type).
nodeReadyReturns true when the Node’s Ready condition status is "True".
nodeRegionReturns the node’s region (label topology.kubernetes.io/region).
nodeTaintsReturns the keys of the node’s taints.
nodeZoneReturns the node’s zone (label topology.kubernetes.io/zone).
podNodeNameReturns the node a pod is scheduled on; "" while pending.

Functions

nodeAllocatableCPU

nodeAllocatableCPU returns status.allocatable.cpu.

{{ nodeAllocatableCPU .node }}  → "3920m"

nodeAllocatableMemory

nodeAllocatableMemory returns status.allocatable.memory.

{{ nodeAllocatableMemory .node }}  → "15032020Ki"

nodeCondition

nodeCondition returns the status string of the named node condition, or "" when absent — common types are Ready, MemoryPressure, and DiskPressure.

{{ nodeCondition .node "MemoryPressure" }}  → "False"

nodeInstanceType

nodeInstanceType returns the node’s instance type (label node.kubernetes.io/instance-type).

{{ nodeInstanceType .node }}  → "m5.large"

nodeReady

nodeReady returns true when the Node’s Ready condition status is "True".

{{ nodeReady .node }}  → true

nodeRegion

nodeRegion returns the node’s region (label topology.kubernetes.io/region).

{{ nodeRegion .node }}  → "us-east-2"

nodeTaints

nodeTaints returns the keys of the node’s taints.

{{ nodeTaints .node }}  → [dedicated]

nodeZone

nodeZone returns the node’s zone (label topology.kubernetes.io/zone).

{{ nodeZone .node }}  → "us-east-2a"

podNodeName

podNodeName returns the node a pod is scheduled on; "" while pending.

{{ podNodeName .pod }}  → "ip-10-0-1-5.us-east-2.compute.internal"