@@ -56,6 +56,7 @@ import (
56
56
"k8s.io/client-go/util/certificate"
57
57
"k8s.io/client-go/util/flowcontrol"
58
58
cloudprovider "k8s.io/cloud-provider"
59
+ "k8s.io/component-helpers/lease"
59
60
internalapi "k8s.io/cri-api/pkg/apis"
60
61
"k8s.io/klog/v2"
61
62
pluginwatcherapi "k8s.io/kubelet/pkg/apis/pluginregistration/v1"
@@ -84,7 +85,6 @@ import (
84
85
"k8s.io/kubernetes/pkg/kubelet/metrics"
85
86
"k8s.io/kubernetes/pkg/kubelet/metrics/collectors"
86
87
"k8s.io/kubernetes/pkg/kubelet/network/dns"
87
- "k8s.io/kubernetes/pkg/kubelet/nodelease"
88
88
oomwatcher "k8s.io/kubernetes/pkg/kubelet/oom"
89
89
"k8s.io/kubernetes/pkg/kubelet/pleg"
90
90
"k8s.io/kubernetes/pkg/kubelet/pluginmanager"
@@ -169,6 +169,9 @@ const (
169
169
170
170
// Minimum number of dead containers to keep in a pod
171
171
minDeadContainerInPod = 1
172
+
173
+ // nodeLeaseRenewIntervalFraction is the fraction of lease duration to renew the lease
174
+ nodeLeaseRenewIntervalFraction = 0.25
172
175
)
173
176
174
177
// SyncHandler is an interface implemented by Kubelet, for testability
@@ -784,7 +787,17 @@ func NewMainKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
784
787
klet .softAdmitHandlers .AddPodAdmitHandler (lifecycle .NewNoNewPrivsAdmitHandler (klet .containerRuntime ))
785
788
klet .softAdmitHandlers .AddPodAdmitHandler (lifecycle .NewProcMountAdmitHandler (klet .containerRuntime ))
786
789
787
- klet .nodeLeaseController = nodelease .NewController (klet .clock , klet .heartbeatClient , string (klet .nodeName ), kubeCfg .NodeLeaseDurationSeconds , klet .onRepeatedHeartbeatFailure )
790
+ leaseDuration := time .Duration (kubeCfg .NodeLeaseDurationSeconds ) * time .Second
791
+ renewInterval := time .Duration (float64 (leaseDuration ) * nodeLeaseRenewIntervalFraction )
792
+ klet .nodeLeaseController = lease .NewController (
793
+ klet .clock ,
794
+ klet .heartbeatClient ,
795
+ string (klet .nodeName ),
796
+ kubeCfg .NodeLeaseDurationSeconds ,
797
+ klet .onRepeatedHeartbeatFailure ,
798
+ renewInterval ,
799
+ v1 .NamespaceNodeLease ,
800
+ util .SetNodeOwnerFunc (klet .heartbeatClient , string (klet .nodeName )))
788
801
789
802
// Finally, put the most recent version of the config on the Kubelet, so
790
803
// people can see how it was configured.
@@ -990,7 +1003,7 @@ type Kubelet struct {
990
1003
updateRuntimeMux sync.Mutex
991
1004
992
1005
// nodeLeaseController claims and renews the node lease for this Kubelet
993
- nodeLeaseController nodelease .Controller
1006
+ nodeLeaseController lease .Controller
994
1007
995
1008
// Generates pod events.
996
1009
pleg pleg.PodLifecycleEventGenerator
0 commit comments