K8s NodeStatus
NodeStatus是Node的一个属性,其记录了由系统最近观察到的节点状态。NodeStatus对用户是只读。NodeStatus还有如下属性:
- addresses:NodeAddress 数组。用于访达节点的地址列表。
- allocatable:Object。节点可用于pod使用的资源。
- capacity:Object。节点资源总容量。
- conditions:NodeCondition 数组。当前节点一系列状态。
- config:NodeConfigStatus。
- daemonEndpoints:NodeDaemonEndpoints。在节点上运行的守护进程的端点。
- images:ContainerImage数组。该节点上的容器镜像。
- nodeInfo:NodeSystemInfo。用于唯一标识节点的一组 ids/uuids。
- phase:String。
- volumesAttached:AttachedVolume数组。
- volumesInUse:String数组。
下面对NodeStatus的属性进行详解
属性详解
addresses
addresses记录可访达节点的地址列表,一般可以包含如下属性:
- HostName
- ExternalIP:外网IP。
- InternalIP:内网IP。
capacity 和 allocatable
capacity 和 allocatable分别表示节点上的总资源容量和可供pod使用的资源容量,默认情况下,如果不进行设置,allocatable就是capacity,即pod可使用节点的所有资源。但这存在一个问题,就是节点不仅仅只运行pod,还要运行系统守护进程和k8s相关组件,这就导致pod会和系统守护进程以及k8s相关组件进行资源的争夺。
因此k8s使用allocatable表明pod使用的资源,capacity表明节点的总资源。为了解决资源争夺问题,需要为系统守护进程以及k8s相关组件预留资源,因此allocatable != capacity,并且capacity-allocatable大致就是预留的资源。
- Kube Reserved:为k8s相关组件运行预留资源。
- System Reserved:为系统守护进程(如sshd, udev)预留资源
- Eviction Thresholds:驱逐阈值资源预留。系统预留一些内存资源,防止系统OOM,当系统可用资源小于驱逐阈值资源,节点为驱逐pod。
资源预留配置示例:www.qikqiak.com/k8strain/ma…
conditions
conditions描述节点运行时的一系列状态。一般有如下状态:
- Ready。True:表明节点是健康的并且可承载pod,False:节点不健康并且不能接受pod调度请求,Unknown:节点在规定时间内没有向节点控制器上传心跳。
- DiskPressure。True:表明磁盘大小存在压力(磁盘可用容量较小)。
- MemoryPressure。True:表明内存存在压力(内存容量过小)。
- PIDPressure。True:表明节点上存在大量的进程。
- NetworkUnavailable。True:表明节点的网络配置错误。
当节点的Ready属性为Unknow或者False时,并且持续时间超过pod-eviction-timeout(默认5分钟),节点控制器会计划将该节点的pod删除,但可能由于无法和节点建立通信导致删除失败。由于无法和节点建立通信,因此需要人工介入处理,手动删除节点。
源码解析
// NodeStatus is information about the current status of a node.
type NodeStatus struct {
// Capacity represents the total resources of a node.
// +optional
Capacity ResourceList
// Allocatable represents the resources of a node that are available for scheduling.
// +optional
Allocatable ResourceList
// NodePhase is the current lifecycle phase of the node.
// +optional
Phase NodePhase
// Conditions is an array of current node conditions.
// +optional
Conditions []NodeCondition
// Queried from cloud provider, if available.
// +optional
Addresses []NodeAddress
// Endpoints of daemons running on the Node.
// +optional
DaemonEndpoints NodeDaemonEndpoints
// Set of ids/uuids to uniquely identify the node.
// +optional
NodeInfo NodeSystemInfo
// List of container images on this node
// +optional
Images []ContainerImage
// List of attachable volumes in use (mounted) by the node.
// +optional
VolumesInUse []UniqueVolumeName
// List of volumes that are attached to the node.
// +optional
VolumesAttached []AttachedVolume
// Status of the config assigned to the node via the dynamic Kubelet config feature.
// +optional
Config *NodeConfigStatus
}
复制代码
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END