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.club.tw/docs/concepts/nodes/node/#manual-node-administration

NodeStatus

NodeStatus 是關於節點當前狀態的資訊。


  • addresses ([]NodeAddress)

    補丁策略:按鍵 type 合併

    對映:合併時將保留鍵型別上的唯一值

    可訪問節點的地址列表。從雲提供商查詢(如果可用)。更多資訊: https://kubernetes.club.tw/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.club.tw/docs/reference/node/node-status/#capacity

  • conditions ([]NodeCondition)

    補丁策略:按鍵 type 合併

    對映:合併時將保留鍵型別上的唯一值

    Conditions 是當前觀測到的節點條件陣列。更多資訊: https://kubernetes.club.tw/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.club.tw/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.club.tw/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)