Node

Node 是 Kubernetes 中的一个工作节点。

apiVersion: v1

import "k8s.io/api/core/v1"

Node

Node 是 Kubernetes 中的一个工作节点。每个节点在缓存(例如 etcd)中都有一个唯一的标识符。


NodeSpec

NodeSpec 描述了节点创建时具有的属性。


  • configSource (NodeConfigSource)

    已弃用:以前用于为 DynamicKubeletConfig 功能指定节点配置的来源。此功能已被移除。

    NodeConfigSource 指定了节点配置的来源。恰好有一个子字段(不包括元数据)必须是非 nil。此 API 自 1.22 版本起已弃用

    • configSource.configMap (ConfigMapNodeConfigSource)

      ConfigMap 是对节点 ConfigMap 的引用

      ConfigMapNodeConfigSource 包含将 ConfigMap 作为节点配置来源的信息。此 API 自 1.22 版本起已弃用: https://git.k8s.io/enhancements/keps/sig-node/281-dynamic-kubelet-configuration

      • configSource.configMap.kubeletConfigKey (string), 必需

        KubeletConfigKey 声明引用的 ConfigMap 中哪个键对应 KubeletConfiguration 结构。此字段在所有情况下都是必需的。

      • configSource.configMap.name (string), 必需

        Name 是引用的 ConfigMap 的 metadata.name。此字段在所有情况下都是必需的。

      • configSource.configMap.namespace (string), 必需

        Namespace 是引用的 ConfigMap 的 metadata.namespace。此字段在所有情况下都是必需的。

      • configSource.configMap.resourceVersion (string)

        ResourceVersion 是引用的 ConfigMap 的 metadata.ResourceVersion。此字段在 Node.Spec 中是禁止的,在 Node.Status 中是必需的。

      • configSource.configMap.uid (string)

        UID 是引用的 ConfigMap 的 metadata.UID。此字段在 Node.Spec 中是禁止的,在 Node.Status 中是必需的。

  • externalID (string)

    已弃用。并非所有 kubelet 都会设置此字段。在 1.13 版本后移除该字段。请参阅: https://issues.k8s.io/61966

  • podCIDR (string)

    PodCIDR 表示分配给节点的 Pod IP 范围。

  • podCIDRs ([]string)

    Set: 合并时将保留唯一值

    podCIDRs 表示分配给节点的 IP 范围,供该节点上的 Pod 使用。如果指定了此字段,则第 0 个条目必须与 podCIDR 字段匹配。它最多可以包含 IPv4 和 IPv6 各一个值。

  • providerID (string)

    云提供商分配的节点 ID,格式为:<ProviderName>://<ProviderSpecificNodeID>

  • taints ([]Taint)

    原子性:在合并期间将被替换

    如果指定,则为节点的污点。

    附加了此 Taint 的节点对任何不容忍此 Taint 的 Pod 都具有“效果”。

    • taints.effect (string), 必需

      必需。污点对不容忍此污点的 Pod 的效果。有效效果是 NoSchedule、PreferNoSchedule 和 NoExecute。

    • taints.key (string), 必需

      必需。要应用于节点的污点键。

    • taints.timeAdded (Time)

      TimeAdded 表示污点添加的时间。

      Time 是 time.Time 的一个包装器,支持正确地编组到 YAML 和 JSON。提供了 time 包提供的许多工厂方法的包装器。

    • taints.value (string)

      与污点键对应的污点值。

  • unschedulable (boolean)

    Unschedulable 控制新 Pod 的节点调度性。默认情况下,节点是可调度的。更多信息: https://kubernetes.ac.cn/docs/concepts/nodes/node/#manual-node-administration

NodeStatus

NodeStatus 是关于节点当前状态的信息。


  • addresses ([]NodeAddress)

    补丁策略:按键 type 合并

    映射:合并时将保留键类型上的唯一值

    可访问节点的地址列表。从云提供商查询(如果可用)。更多信息: https://kubernetes.ac.cn/docs/reference/node/node-status/#addresses 注意:此字段被声明为可合并,但合并键的唯一性不足,这可能导致合并时数据损坏。调用者应改为使用完全替换补丁。有关示例,请参阅 https://pr.k8s.io/79391。消费者应假设地址在节点的生命周期内可能会发生变化。但是,有些例外情况可能无法实现,例如继承节点地址的 Pod 自身状态或向下 API(status.hostIP)的消费者。

    NodeAddress 包含节点地址的信息。

    • addresses.address (string), 必需

      节点地址。

    • addresses.type (string), 必需

      节点地址类型,为 Hostname、ExternalIP 或 InternalIP 之一。

  • allocatable (map[string]Quantity)

    Allocatable 表示可供调度的节点资源。默认为 Capacity。

  • capacity (map[string]Quantity)

    Capacity 表示节点总资源。更多信息: https://kubernetes.ac.cn/docs/reference/node/node-status/#capacity

  • conditions ([]NodeCondition)

    补丁策略:按键 type 合并

    映射:合并时将保留键类型上的唯一值

    Conditions 是当前观测到的节点条件数组。更多信息: https://kubernetes.ac.cn/docs/reference/node/node-status/#condition

    NodeCondition 包含节点的条件信息。

    • conditions.status (string),必需

      条件的 status,可以是 True、False、Unknown 之一。

    • conditions.type (string),必需

      节点条件的类型。

    • conditions.lastHeartbeatTime (Time)

      我们最后一次获得某个条件的更新时间。

      Time 是 time.Time 的一个包装器,支持正确地编组到 YAML 和 JSON。提供了 time 包提供的许多工厂方法的包装器。

    • conditions.lastTransitionTime (Time)

      条件从一个状态转换到另一个状态的最后时间。

      Time 是 time.Time 的一个包装器,支持正确地编组到 YAML 和 JSON。提供了 time 包提供的许多工厂方法的包装器。

    • conditions.message (string)

      关于最后一次转换的详细信息的易读消息。

    • conditions.reason (string)

      条件最后一次转换的(简要)原因。

  • config (NodeConfigStatus)

    通过动态 Kubelet 配置功能分配给节点的配置状态。

    NodeConfigStatus 描述了 Node.Spec.ConfigSource 分配的配置状态。

    • config.active (NodeConfigSource)

      Active 报告节点正在积极使用的检查点配置。Active 将代表 Assigned 配置的当前版本,或当前 LastKnownGood 配置,具体取决于尝试使用 Assigned 配置是否会产生错误。Active 仅在 Assigned 配置成功成为 LastKnownGood 时更新。

      NodeConfigSource 指定了节点配置的来源。恰好有一个子字段(不包括元数据)必须是非 nil。此 API 自 1.22 版本起已弃用

      • config.active.configMap (ConfigMapNodeConfigSource)

        ConfigMap 是对节点 ConfigMap 的引用

        ConfigMapNodeConfigSource 包含将 ConfigMap 作为节点配置来源的信息。此 API 自 1.22 版本起已弃用: https://git.k8s.io/enhancements/keps/sig-node/281-dynamic-kubelet-configuration

        • config.active.configMap.kubeletConfigKey (string), 必需

          KubeletConfigKey 声明引用的 ConfigMap 中哪个键对应 KubeletConfiguration 结构。此字段在所有情况下都是必需的。

        • config.active.configMap.name (string), 必需

          Name 是引用的 ConfigMap 的 metadata.name。此字段在所有情况下都是必需的。

        • config.active.configMap.namespace (string), 必需

          Namespace 是引用的 ConfigMap 的 metadata.namespace。此字段在所有情况下都是必需的。

        • config.active.configMap.resourceVersion (string)

          ResourceVersion 是引用的 ConfigMap 的 metadata.ResourceVersion。此字段在 Node.Spec 中是禁止的,在 Node.Status 中是必需的。

        • config.active.configMap.uid (string)

          UID 是引用的 ConfigMap 的 metadata.UID。此字段在 Node.Spec 中是禁止的,在 Node.Status 中是必需的。

    • config.assigned (NodeConfigSource)

      Assigned 报告节点将尝试使用的检查点配置。当 Node.Spec.ConfigSource 更新时,节点会将相关的配置负载检查点保存到本地磁盘,并附带一个指示预期配置的记录。节点通过此记录选择其配置检查点,并在 Assigned 中报告此记录。仅当记录已检查点保存到磁盘后,Assigned 才会更新状态。当 Kubelet 重启时,它会尝试通过加载和验证 Assigned 标识的检查点负载来使 Assigned 配置成为 Active 配置。

      NodeConfigSource 指定了节点配置的来源。恰好有一个子字段(不包括元数据)必须是非 nil。此 API 自 1.22 版本起已弃用

      • config.assigned.configMap (ConfigMapNodeConfigSource)

        ConfigMap 是对节点 ConfigMap 的引用

        ConfigMapNodeConfigSource 包含将 ConfigMap 作为节点配置来源的信息。此 API 自 1.22 版本起已弃用: https://git.k8s.io/enhancements/keps/sig-node/281-dynamic-kubelet-configuration

        • config.assigned.configMap.kubeletConfigKey (string), 必需

          KubeletConfigKey 声明引用的 ConfigMap 中哪个键对应 KubeletConfiguration 结构。此字段在所有情况下都是必需的。

        • config.assigned.configMap.name (string), 必需

          Name 是引用的 ConfigMap 的 metadata.name。此字段在所有情况下都是必需的。

        • config.assigned.configMap.namespace (string), 必需

          Namespace 是引用的 ConfigMap 的 metadata.namespace。此字段在所有情况下都是必需的。

        • config.assigned.configMap.resourceVersion (string)

          ResourceVersion 是引用的 ConfigMap 的 metadata.ResourceVersion。此字段在 Node.Spec 中是禁止的,在 Node.Status 中是必需的。

        • config.assigned.configMap.uid (string)

          UID 是引用的 ConfigMap 的 metadata.UID。此字段在 Node.Spec 中是禁止的,在 Node.Status 中是必需的。

    • config.error (string)

      Error 描述了在协调 Spec.ConfigSource 到 Active 配置过程中出现的任何问题。例如,尝试将 Spec.ConfigSource 检查点保存到本地 Assigned 记录、尝试检查点保存 Spec.ConfigSource 关联的负载、尝试加载或验证 Assigned 配置等都可能发生错误。错误可能在同步配置的不同点发生。早期错误(例如下载或检查点错误)不会导致回滚到 LastKnownGood,并且可能在 Kubelet 重试中得到解决。后期错误(例如加载或验证检查点配置)将导致回滚到 LastKnownGood。在后一种情况下,通常可以通过修复 Spec.ConfigSource 中分配的配置来解决错误。您可以通过在 Kubelet 日志中搜索错误消息来找到用于调试的额外信息。Error 是错误状态的可读描述;机器可以检查 Error 是否为空,但不应依赖 Error 文本在 Kubelet 版本之间的稳定性。

    • config.lastKnownGood (NodeConfigSource)

      LastKnownGood 报告节点在遇到错误尝试使用 Assigned 配置时将回滚到的检查点配置。当节点确定 Assigned 配置稳定且正确时,Assigned 配置将成为 LastKnownGood 配置。目前实现为在本地 Assigned 配置记录更新后开始的 10 分钟稳定期。如果在稳定期结束时 Assigned 配置处于 Active 状态,它将成为 LastKnownGood。请注意,如果 Spec.ConfigSource 被重置为 nil(使用本地默认值),LastKnownGood 也会立即重置为 nil,因为本地默认配置始终被认为是好的。您不应对节点确定配置稳定性和正确性的方法做出假设,因为这可能会在未来发生变化或变得可配置。

      NodeConfigSource 指定了节点配置的来源。恰好有一个子字段(不包括元数据)必须是非 nil。此 API 自 1.22 版本起已弃用

      • config.lastKnownGood.configMap (ConfigMapNodeConfigSource)

        ConfigMap 是对节点 ConfigMap 的引用

        ConfigMapNodeConfigSource 包含将 ConfigMap 作为节点配置来源的信息。此 API 自 1.22 版本起已弃用: https://git.k8s.io/enhancements/keps/sig-node/281-dynamic-kubelet-configuration

        • config.lastKnownGood.configMap.kubeletConfigKey (string), 必需

          KubeletConfigKey 声明引用的 ConfigMap 中哪个键对应 KubeletConfiguration 结构。此字段在所有情况下都是必需的。

        • config.lastKnownGood.configMap.name (string), 必需

          Name 是引用的 ConfigMap 的 metadata.name。此字段在所有情况下都是必需的。

        • config.lastKnownGood.configMap.namespace (string), 必需

          Namespace 是引用的 ConfigMap 的 metadata.namespace。此字段在所有情况下都是必需的。

        • config.lastKnownGood.configMap.resourceVersion (string)

          ResourceVersion 是引用的 ConfigMap 的 metadata.ResourceVersion。此字段在 Node.Spec 中是禁止的,在 Node.Status 中是必需的。

        • config.lastKnownGood.configMap.uid (string)

          UID 是引用的 ConfigMap 的 metadata.UID。此字段在 Node.Spec 中是禁止的,在 Node.Status 中是必需的。

  • daemonEndpoints (NodeDaemonEndpoints)

    节点上运行的守护进程的端点。

    NodeDaemonEndpoints 列出了节点上运行的守护进程打开的端口。

    • daemonEndpoints.kubeletEndpoint (DaemonEndpoint)

      Kubelet 正在监听的端点。

      DaemonEndpoint 包含单个 Daemon 端点的信息。

      • daemonEndpoints.kubeletEndpoint.Port (int32), 必需

        给定端点的端口号。

  • features (NodeFeatures)

    Features 描述了 CRI 实现所实现的特性集。

    NodeFeatures 描述了 CRI 实现所实现的特性集。NodeFeatures 中包含的特性应仅取决于 CRI 实现,与运行时处理程序无关。

    • features.supplementalGroupsPolicy (boolean)

      如果运行时支持 SupplementalGroupsPolicy 和 ContainerUser,则 SupplementalGroupsPolicy 设置为 true。

  • images ([]ContainerImage)

    原子性:在合并期间将被替换

    此节点上的容器镜像列表

    描述一个容器镜像

    • images.names ([]string)

      原子性:在合并期间将被替换

      此镜像的已知名称。例如:["kubernetes.example/hyperkube:v1.0.7", "cloud-vendor.registry.example/cloud-vendor/hyperkube:v1.0.7"]

    • images.sizeBytes (int64)

      镜像的字节大小。

  • nodeInfo (NodeSystemInfo)

    一组 ID/UUID,用于唯一标识节点。更多信息: https://kubernetes.ac.cn/docs/reference/node/node-status/#info

    NodeSystemInfo 是一组 ID/UUID,用于唯一标识节点。

    • nodeInfo.architecture (string), 必需

      节点报告的架构

    • nodeInfo.bootID (string), 必需

      节点报告的启动 ID。

    • nodeInfo.containerRuntimeVersion (string), 必需

      节点通过运行时远程 API(例如 containerd://1.4.2)报告的容器运行时版本。

    • nodeInfo.kernelVersion (string), 必需

      节点从 'uname -r' 报告的内核版本(例如 3.16.0-0.bpo.4-amd64)。

    • nodeInfo.kubeProxyVersion (string), 必需

      已弃用:节点报告的 KubeProxy 版本。

    • nodeInfo.kubeletVersion (string), 必需

      节点报告的 Kubelet 版本。

    • nodeInfo.machineID (string), 必需

      节点报告的 MachineID。对于集群中的唯一机器标识,此字段是首选。了解更多信息请参阅 man(5) machine-id: http://man7.org/linux/man-pages/man5/machine-id.5.html

    • nodeInfo.operatingSystem (string), 必需

      节点报告的操作系统

    • nodeInfo.osImage (string), 必需

      节点从 /etc/os-release 报告的操作系统镜像(例如 Debian GNU/Linux 7 (wheezy))。

    • nodeInfo.systemUUID (string), 必需

      节点报告的 SystemUUID。对于唯一的机器标识,首选 MachineID。此字段特定于 Red Hat 主机 https://access.redhat.com/documentation/en-us/red_hat_subscription_management/1/html/rhsm/uuid

    • nodeInfo.swap (NodeSwapStatus)

      节点报告的 Swap 信息。

      NodeSwapStatus 表示 Swap 内存信息。

      • nodeInfo.swap.capacity (int64)

        Swap 内存的总量(字节)。

  • phase (string)

    NodePhase 是节点最近观测到的生命周期阶段。更多信息: https://kubernetes.ac.cn/docs/concepts/nodes/node/#phase 该字段从不填充,现在已弃用。

  • runtimeHandlers ([]NodeRuntimeHandler)

    原子性:在合并期间将被替换

    可用的运行时处理程序。

    NodeRuntimeHandler 是一组运行时处理程序信息。

    • runtimeHandlers.features (NodeRuntimeHandlerFeatures)

      支持的特性。

      NodeRuntimeHandlerFeatures 是一组运行时处理程序实现的特性。

      • runtimeHandlers.features.recursiveReadOnlyMounts (boolean)

        如果运行时处理程序支持 RecursiveReadOnlyMounts,则 RecursiveReadOnlyMounts 设置为 true。

      • runtimeHandlers.features.userNamespaces (boolean)

        如果运行时处理程序支持 UserNamespaces(包括卷),则 UserNamespaces 设置为 true。

    • runtimeHandlers.name (string)

      运行时处理程序名称。对于默认运行时处理程序为空。

  • volumesAttached ([]AttachedVolume)

    原子性:在合并期间将被替换

    已连接到节点的卷列表。

    AttachedVolume 描述已连接到节点的卷

    • volumesAttached.devicePath (string), 必需

      DevicePath 表示卷应可用的设备路径

    • volumesAttached.name (string), 必需

      已连接卷的名称

  • volumesInUse ([]string)

    原子性:在合并期间将被替换

    节点正在使用(挂载)的可连接卷列表。

NodeList

NodeList 是已注册到 master 的所有 Node 的完整列表。


操作


get 读取指定的 Node

HTTP 请求

GET /api/v1/nodes/{name}

参数

  • name (在路径中): string,必填

    Node 的名称

  • pretty (在查询中): string

    pretty

响应

200 (Node): OK

401: 未授权

get 读取指定 Node 的状态

HTTP 请求

GET /api/v1/nodes/{name}/status

参数

  • name (在路径中): string,必填

    Node 的名称

  • pretty (在查询中): string

    pretty

响应

200 (Node): OK

401: 未授权

list 列出或监视 Node 类型的对象

HTTP 请求

GET /api/v1/nodes

参数

响应

200 (NodeList): OK

401: 未授权

create 创建一个 Node

HTTP 请求

POST /api/v1/nodes

参数

响应

200 (Node): OK

201 (Node): Created

202 (Node): Accepted

401: 未授权

update 替换指定的 Node

HTTP 请求

PUT /api/v1/nodes/{name}

参数

  • name (在路径中): string,必填

    Node 的名称

  • body: Node, 必需

  • dryRun (在查询中): string

    dryRun

  • fieldManager (在查询中): string

    fieldManager

  • fieldValidation (在查询中): string

    fieldValidation

  • pretty (在查询中): string

    pretty

响应

200 (Node): OK

201 (Node): Created

401: 未授权

update 替换指定 Node 的状态

HTTP 请求

PUT /api/v1/nodes/{name}/status

参数

  • name (在路径中): string,必填

    Node 的名称

  • body: Node, 必需

  • dryRun (在查询中): string

    dryRun

  • fieldManager (在查询中): string

    fieldManager

  • fieldValidation (在查询中): string

    fieldValidation

  • pretty (在查询中): string

    pretty

响应

200 (Node): OK

201 (Node): Created

401: 未授权

patch 部分更新指定的 Node

HTTP 请求

PATCH /api/v1/nodes/{name}

参数

  • name (在路径中): string,必填

    Node 的名称

  • body: Patch,必需

  • dryRun (在查询中): string

    dryRun

  • fieldManager (在查询中): string

    fieldManager

  • fieldValidation (在查询中): string

    fieldValidation

  • force (在查询中): boolean

    force

  • pretty (在查询中): string

    pretty

响应

200 (Node): OK

201 (Node): Created

401: 未授权

patch 部分更新指定 Node 的状态

HTTP 请求

PATCH /api/v1/nodes/{name}/status

参数

  • name (在路径中): string,必填

    Node 的名称

  • body: Patch,必需

  • dryRun (在查询中): string

    dryRun

  • fieldManager (在查询中): string

    fieldManager

  • fieldValidation (在查询中): string

    fieldValidation

  • force (在查询中): boolean

    force

  • pretty (在查询中): string

    pretty

响应

200 (Node): OK

201 (Node): Created

401: 未授权

delete 删除一个 Node

HTTP 请求

DELETE /api/v1/nodes/{name}

参数

响应

200 (Status): OK

202 (Status): 已接受

401: 未授权

deletecollection 删除 Node 的集合

HTTP 请求

DELETE /api/v1/nodes

参数

响应

200 (Status): OK

401: 未授权

本页面是自动生成的。

如果你打算报告此页面存在的问题,请在问题描述中提及此页面是自动生成的。修复可能需要在 Kubernetes 项目的其他地方进行。

上次修改时间:2025 年 9 月 4 日 下午 3:37 PST:更新 v1.34 的 API 资源参考 (3e10e8c195)