Upgrading Linux nodes
Kubernetes Docs · نسخهٔ f284a9e7c87f · CC BY 4.0 برای مستندات و مجوزهای همراه
<!-- overview -->
This page explains how to upgrade a Linux Worker Nodes created with kubeadm.
{{% heading "prerequisites" %}}
{{< include "task-tutorial-prereqs-node-upgrade.md" >}} {{< version-check >}}
- Familiarize yourself with [the process for upgrading the rest of your kubeadm
cluster](/docs/tasks/administer-cluster/kubeadm/kubeadm-upgrade). You will want to upgrade the control plane nodes before upgrading your Linux Worker nodes.
<!-- steps -->
Changing the package repository
If you're using the community-owned package repositories (pkgs.k8s.io), you need to enable the package repository for the desired Kubernetes minor release. This is explained in Changing the Kubernetes package repository document.
{{% legacy-repos-deprecation %}}
Upgrading worker nodes
Upgrade kubeadm and kubectl
Upgrade kubeadm and kubectl:
{{< note >}} kubectl must be within one minor version of kube-apiserver as per the version skew policy. If you are upgrading the control plane across multiple minor versions before upgrading worker nodes, the node-local kubectl may fall outside the allowed skew. Upgrading kubectl alongside kubeadm here ensures it stays within the supported version range throughout the node upgrade process. {{< /note >}}
{{< tabs name="k8s_install_kubeadm_worker_nodes" >}} {{% tab name="Ubuntu, Debian or HypriotOS" %}}
# replace x in {{< skew currentVersion >}}.x-* with the latest patch version
sudo apt-mark unhold kubeadm kubectl && \
sudo apt-get update && sudo apt-get install -y kubeadm='{{< skew currentVersion >}}.x-*' kubectl='{{< skew currentVersion >}}.x-*' && \
sudo apt-mark hold kubeadm kubectl{{% /tab %}} {{% tab name="CentOS, RHEL or Fedora" %}} For systems with DNF4 (Fedora < 41, RHEL/Centos < 10):
# replace x in {{< skew currentVersion >}}.x-* with the latest patch version
sudo dnf install -y kubeadm-'{{< skew currentVersion >}}.x-*' kubectl-'{{< skew currentVersion >}}.x-*' --disableexcludes=kubernetesFor systems with DNF5:
# replace x in {{< skew currentVersion >}}.x-* with the latest patch version
sudo dnf install -y kubeadm-'{{< skew currentVersion >}}.x-*' kubectl-'{{< skew currentVersion >}}.x-*' --setopt=disable_excludes=kubernetes{{% /tab %}} {{< /tabs >}}
Call "kubeadm upgrade"
For worker nodes this upgrades the local kubelet configuration:
sudo kubeadm upgrade nodeDrain the node
Prepare the node for maintenance by marking it unschedulable and evicting the workloads:
# execute this command on a control plane node
# replace <node-to-drain> with the name of your node you are draining
kubectl drain <node-to-drain> --ignore-daemonsetsUpgrade kubelet
- Upgrade the kubelet:
{{< tabs name="k8s_kubelet_and_kubectl" >}} {{% tab name="Ubuntu, Debian or HypriotOS" %}}
# replace x in {{< skew currentVersion >}}.x-* with the latest patch version
sudo apt-mark unhold kubelet && \
sudo apt-get update && sudo apt-get install -y kubelet='{{< skew currentVersion >}}.x-*' && \
sudo apt-mark hold kubelet{{% /tab %}} {{% tab name="CentOS, RHEL or Fedora" %}} For systems with DNF4 (Fedora < 41, RHEL/CentOS < 10):
# replace x in {{< skew currentVersion >}}.x-* with the latest patch version
sudo dnf install -y kubelet-'{{< skew currentVersion >}}.x-*' --disableexcludes=kubernetesFor systems with DNF5:
# replace x in {{< skew currentVersion >}}.x-* with the latest patch version
sudo dnf install -y kubelet-'{{< skew currentVersion >}}.x-*' --setopt=disable_excludes=kubernetes{{% /tab %}} {{< /tabs >}}
- Restart the kubelet:
sudo systemctl daemon-reload
sudo systemctl restart kubeletUncordon the node
Bring the node back online by marking it schedulable:
# execute this command on a control plane node
# replace <node-to-uncordon> with the name of your node
kubectl uncordon <node-to-uncordon>{{% heading "whatsnext" %}}
- See how to Upgrade Windows nodes.