<p>How does Kubernetes create the Leases resource for an ETCD cluster to view the leader information?</p>
<pre><code>$ kubectl get leases
NAME                      HOLDER                                                       AGE
kube-controller-manager   master01.k8s-host.com_68f9a489-4e8c-4dc6-a9c2-6136d4cf7798   22h
kube-scheduler            master01.k8s-host.com_b1a8a9a3-e2bb-4102-84a4-b046b8776bdb   21h
</code></pre>
<pre><code>$ kubectl version
Client Version: version.Info{Major:&quot;1&quot;, Minor:&quot;20&quot;, GitVersion:&quot;v1.20.8&quot;, GitCommit:&quot;5575935422cc1cf5169dfc8847cb587aa47bac5a&quot;, GitTreeState:&quot;clean&quot;, BuildDate:&quot;2021-06-16T13:00:45Z&quot;, GoVersion:&quot;go1.15.13&quot;, Compiler:&quot;gc&quot;, Platform:&quot;linux/amd64&quot;}
</code></pre>
<pre><code>$ etcd version
etcd Version: 3.4.16
Git SHA: d19fbe541
Go Version: go1.12.17
Go OS/Arch: linux/amd64
</code></pre>

Xsky
<p>Partial answer that may help you. However, maybe you want to rephrase the &quot;How does Kubernetes create the Leases resource&quot;. Tbh not clear whether you wanna check verbose output of whats going on in the background or you wanna understand the main idea and steps.</p>
<p>What I found is pretty comprehensive etcd article <a href="https://www.alibabacloud.com/blog/getting-started-with-kubernetes-%7C-etcd_596292" rel="nofollow noreferrer">Getting Started with Kubernetes | etcd | LEASE part</a></p>
<blockquote>
<p>Lease is commonly used to represent a distributed lease in distributed
systems. Typically, the lease mechanism is required to detect whether
a node is alive in a distributed system.</p>
</blockquote>
<p><a href="https://i.stack.imgur.com/ev5R9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ev5R9.png" alt="enter image description here" /></a></p>
<blockquote>
<p>As shown in the preceding figure, a 10-second lease is created. If you
do not perform any operations after the lease is created, the lease
automatically expires after 10 seconds. Bind key1 and key2 to the
lease so that etcd automatically clears key1 and key2 when the lease
expires.</p>
<p>If you want to keep the lease, you need to periodically call the
KeeyAlive method to refresh it. For example, to check whether a
process in a distributed system is alive, you can create a lease in
the process and periodically call the KeepAlive method in the process.
If the process is normal, the lease on this node is kept. If the
process crashes, the lease automatically expires.</p>
<p>However, if a large number of keys need to support a similar lease
mechanism, and the lease must be refreshed for each key independently,
this puts a great deal of pressure on etcd. Therefore, etcd allows the
binding of multiple keys (for example, keys with similar expiration
times) to the same lease, which can greatly reduce the overhead of
lease refresh and improve etcd performance.</p>
</blockquote>
