⚡ ~/naveed Interview Prep
⚡ Portfolio Home 👤 About Naveed Bio & Credentials 📫 Contact Naveed Get In Touch ✍️ Engineering Blog Deep Dives 🎯 Interview Hub 1,000+ Scenarios ☸️ Kubernetes Mastery Hub 24 Modules 🎮 DevOps Arcade & Quizzes Subnet Blitz ⚡ 🗺️ DevOps Roadmaps PDFs & Guides 🤖 Morpheus Analysis AI Quant ↗ 🛠️ Developer Tools Utilities 🧪 Labs & Experiments 📄 Interactive CV & Certs 🔗 All Links & Socials ⚡ Join The Dispatch (Weekly SRE Newsletter) →
← Back to All Kubernetes Interview Questions Scenario 143 of 207 in Kubernetes
Senior DevOps / SRE [L2] Kubernetes Additional Kubernetes Scenarios (Q101-Q200) Production Scenario [L2]
🎯 Target Role / Context: Kubernetes Scenario #133 (L2) · Additional Kubernetes Scenarios (Q101-Q200)

Q: What is a Kubernetes lease?

A Kubernetes Lease is a small coordination.k8s.io/v1 object that records which holder owns something and when it last renewed it.

#Kubernetes #L2 #Container Orchestration #K8s
🎙️ Candidate Opening & Architectural Context
"<strong>A Kubernetes Lease</strong> is a small <code>coordination.k8s.io/v1</code> object that records which holder owns something and when it last renewed it. Kubernetes uses Leases for two main jobs: node heartbeats (one Lease per node in <code>kube-node-lease</code>) and leader election for components like kube-scheduler, kube-controller-manager and custom controllers. Interviewers ask about it because Leases explain how the control plane detects dead nodes cheaply and how HA controllers avoid running active-active, which ties directly to NotReady and failover troubleshooting."
Advertisement
⚡ Recommended Practice Lab

Want to master this scenario in a live sandbox? KodeKloud's CKA & CKAD Hands-On Certification Track covers this exact problem with hands-on terminal drills.

🛠️ Production Runbook & Step-by-Step Resolution

Direct Answer: <strong>A Kubernetes Lease</strong> is a small <code>coordination.k8s.io/v1</code> object that records which holder owns something and when it last renewed it. Kubernetes uses Leases for two main jobs: node heartbeats (one Lease per node in <code>kube-node-lease</code>) and leader election for components like kube-scheduler, kube-controller-manager and custom controllers. Interviewers ask about it because Leases explain how the control plane detects dead nodes cheaply and how HA controllers avoid running active-active, which ties directly to NotReady and failover troubleshooting.

1️⃣

Kubernetes Lease anatomy

A Lease is a tiny record of ownership plus a renewal clock.

kubectl get leases -A
kubectl get lease my-node-1 -n kube-node-lease -o yaml
# spec: holderIdentity, leaseDurationSeconds, renewTime
  • holderIdentity: who currently holds it, such as a node name or a pod identity.
  • leaseDurationSeconds: how long others should wait after the last renewal before treating it as expired.
  • renewTime / acquireTime: timestamps updated by the holder; leaseTransitions counts ownership changes.
  • Why a separate object: updating a small Lease is much cheaper for etcd and watchers than rewriting a large Node status.
2️⃣

Node heartbeats

Each kubelet renews its own Lease regularly.

kubectl get lease -n kube-node-lease
kubectl get lease my-node-1 -n kube-node-lease -o jsonpath='{.spec.renewTime}{"\n"}'
date -u +%Y-%m-%dT%H:%M:%SZ   # compare with renewTime
  • Renewal: the kubelet renews its Lease roughly every 10 seconds, with a lease duration of 40 seconds by default.
  • Detection: the node lifecycle controller marks a node Unknown when heartbeats stop for node-monitor-grace-period (40s default).
  • Node status: full Node status updates now happen on change or at a slower interval, because the Lease carries the liveness signal.
  • Troubleshooting: a stale renewTime points to a dead kubelet or broken connectivity to the API server.
Advertisement
3️⃣

Leader election for controllers

Replicas compete for a Lease and only the holder acts.

kubectl get lease kube-scheduler -n kube-system -o jsonpath='{.spec.holderIdentity}{"\n"}'

# RBAC for a controller using Lease-based election
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: leader-election
  namespace: my-system
rules:
- apiGroups: ["coordination.k8s.io"]
  resources: ["leases"]
  verbs: ["get", "list", "watch", "create", "update", "patch"]
  • Core components: kube-scheduler and kube-controller-manager hold Leases in kube-system when run in HA mode.
  • Typical defaults: lease duration 15s, renew deadline 10s, retry period 2s.
  • Failover: if the leader stops renewing, another replica acquires the Lease after expiry and takes over.
  • Custom controllers: client-go and controller-runtime use Leases for election, which needs RBAC on leases.
Pro Tip: A Lease provides leader election with failover but it is not a hard lock: a paused leader may briefly believe it still leads, so operators should stop work when renewal fails.
4️⃣

Failure modes and diagnosis

Most Lease problems are timing, permissions or API server health.

  • Leader flapping: slow API server or etcd makes renewals miss the deadline, causing repeated elections and restarts.
  • Forbidden errors: missing RBAC on leases prevents election; controller logs show the denial.
  • Clock issues: comparisons rely on observed timing, but large clock drift on nodes still complicates debugging timestamps.
  • Stuck holder: a deleted Lease is recreated, but an old holder running split leader code can produce duplicate actions if it ignores lost leadership.
5️⃣

Production practice

Monitor Leases like any other control plane signal.

  • Alert on transitions: a rising leaseTransitions value signals instability.
  • Tune carefully: longer lease durations tolerate API latency but slow failover.
  • One election per controller: use a unique Lease name and namespace for each operator deployment.
  • API server identity: newer versions also publish kube-apiserver identity Leases in kube-system, useful for counting live API servers.
💡 The Senior SRE Gold Nugget (Key Architectural Takeaway)
"Pro-Tip: When a node flips to NotReady, check the renewTime of its Lease in kube-node-lease first, and treat rising leaseTransitions on kube-system Leases as an early warning of control plane latency."
⚡ 60-Second Elevator Pitch Talking Points
  • A Lease is a small coordination.k8s.io object with a holder, a duration and a renew time, used as a cheap heartbeat and election primitive.
  • I check node health through the Lease renewTime in kube-node-lease and leader ownership through holderIdentity in kube-system.
  • I make sure controllers have RBAC for leases and alert on frequent leaseTransitions.
⛔ Critical Candidate Mistakes to Avoid in This Scenario

Senior hiring managers and bar raisers evaluate how you prioritize during outages. Avoid these common anti-patterns:

  1. Forgetting RBAC for the coordination.k8s.io leases resource in custom controllers Leader election fails and the controller never becomes active or crash-loops.
  2. Treating Lease leadership as a perfect mutual-exclusion lock A paused or partitioned leader can briefly act after expiry, so work must stop when renewal fails.
  3. Setting very short lease durations to speed up failover Normal API latency spikes then cause leadership flapping and repeated restarts.
  4. Looking only at the Node status when diagnosing NotReady The Lease renewTime shows the real heartbeat age and tells you how long the kubelet has been silent.
Advertisement
📥 FREE DOWNLOAD · 101-PAGE COMPANION HANDBOOK
Studying for Kubernetes & SRE Technical Rounds?
Download the complete 100-question PDF field guide covering all 11 core modules with offline diagnostic runbooks.
📥 Download PDF (Free) Read Online Guide →
Want more Kubernetes scenarios?
Explore our complete collection of scenario-based Kubernetes interview runbooks.
Browse All Kubernetes Questions →