kubelet默认会每5分钟一次更新node status,包括更新lastHeartbeatTime。 更新周期是由node-status-update-frequency 控制的

  1. // syncNodeStatus should be called periodically from a goroutine.
  2. // It synchronizes node status to master if there is any change or enough time
  3. // passed from the last sync, registering the kubelet first if necessary.
  4. func (kl *Kubelet) syncNodeStatus() {
  5. kl.syncNodeStatusMux.Lock()
  6. defer kl.syncNodeStatusMux.Unlock()
  7. if kl.kubeClient == nil || kl.heartbeatClient == nil {
  8. return
  9. }
  10. if kl.registerNode {
  11. // This will exit immediately if it doesn't need to do anything.
  12. kl.registerWithAPIServer()
  13. }
  14. if err := kl.updateNodeStatus(); err != nil {
  15. klog.ErrorS(err, "Unable to update node status")
  16. }
  17. }

lease

为了减轻apiserver、etcd的压力,使用lease来做更短的心跳保持。
kubelet中有nodeLeaseController,默认每10s一次,定时更新lease信息。