Skip to main content

Module node_lease

Module node_lease 

Source
Expand description

NODE HEARTBEATS — the Lease a node renews to prove it is alive.

★ WHY THIS EXISTS. A Node was registered once at boot with a hardcoded [{type: Ready, status: True}] and nothing ever updated it again. The kube-node-lease namespace was seeded and coordination.k8s.io was served, but no Lease was ever written or renewed. The consequence is the worst kind of monitoring failure: a node that has crashed, partitioned, or been powered off reports Ready forever. A scheduler keeps placing pods on it; kubectl get nodes shows a healthy cluster; nothing ever transitions to NotReady.

★ WHY A LEASE AND NOT A STATUS WRITE. Upstream moved node heartbeats to coordination.k8s.io/v1 Lease precisely because writing Node.status every few seconds is expensive — the object is large, every write wakes every Node watcher, and on a big cluster that traffic dominates the apiserver. A Lease is a tiny object whose only job is to carry renewTime. engenho gets the same property for the same reason, and gets it in the shape every existing tool already reads.

★ LIVENESS IS DERIVED, NEVER ASSERTED. Ready is computed from the lease’s age against a grace period. Nothing writes “I am healthy” — a node proves it by renewing, and stops proving it by failing to. That inversion is the entire point: an asserted condition survives the death of whatever asserted it, which is exactly the bug being fixed here.

★ CLOCK-INJECTED AND PURE, so the whole grace-period curve is tested without sleeping.

Enums§

NodeReadiness
A node’s readiness, DERIVED from how stale its heartbeat is.

Constants§

GRACE_PERIOD
How stale a lease may get before the node is judged NodeReadiness::Stale.
LEASE_NAMESPACE
The namespace node leases live in.
RENEW_INTERVAL
How often a node renews its lease. Upstream’s default.

Functions§

find_ready_condition
Find the Ready condition in a Node’s status.conditions, if present.
lease_key
The store key for a node’s lease.
lease_value
Build the Lease object for a node.
project_ready_condition
Project the Ready condition a Node’s Lease implies onto that Node.
readiness
Judge a node from the age of its last heartbeat.
ready_condition
The Ready condition to publish on Node.status.