website/content/en/docs/tasks/administer-cluster/kubeadm/upgrading-linux-nodes.md

3.1 KiB

title content_type weight
Upgrading Linux nodes task 100

This page explains how to upgrade a Linux Worker Nodes created with kubeadm.

{{% heading "prerequisites" %}}

{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}

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

Upgrade kubeadm:

{{< tabs name="k8s_install_kubeadm_worker_nodes" >}} {{% tab name="Ubuntu, Debian or HypriotOS" %}}

# replace x in {{< skew currentVersion >}}.x-* with the latest patch version
apt-mark unhold kubeadm && \
apt-get update && apt-get install -y kubeadm='{{< skew currentVersion >}}.x-*' && \
apt-mark hold kubeadm

{{% /tab %}} {{% tab name="CentOS, RHEL or Fedora" %}}

# replace x in {{< skew currentVersion >}}.x-* with the latest patch version
yum install -y kubeadm-'{{< skew currentVersion >}}.x-*' --disableexcludes=kubernetes

{{% /tab %}} {{< /tabs >}}

Call "kubeadm upgrade"

For worker nodes this upgrades the local kubelet configuration:

sudo kubeadm upgrade node

Drain the node

Prepare the node for maintenance by marking it unschedulable and evicting the workloads:

# replace <node-to-drain> with the name of your node you are draining
kubectl drain <node-to-drain> --ignore-daemonsets

Upgrade kubelet and kubectl

  1. Upgrade the kubelet and kubectl:

    {{< tabs name="k8s_kubelet_and_kubectl" >}} {{% tab name="Ubuntu, Debian or HypriotOS" %}}

    # replace x in {{< skew currentVersion >}}.x-* with the latest patch version
    apt-mark unhold kubelet kubectl && \
    apt-get update && apt-get install -y kubelet='{{< skew currentVersion >}}.x-*' kubectl='{{< skew currentVersion >}}.x-*' && \
    apt-mark hold kubelet kubectl
    

    {{% /tab %}} {{% tab name="CentOS, RHEL or Fedora" %}}

    # replace x in {{< skew currentVersion >}}.x-* with the latest patch version
    yum install -y kubelet-'{{< skew currentVersion >}}.x-*' kubectl-'{{< skew currentVersion >}}.x-*' --disableexcludes=kubernetes
    

    {{% /tab %}} {{< /tabs >}}

  2. Restart the kubelet:

    sudo systemctl daemon-reload
    sudo systemctl restart kubelet
    

Uncordon the node

Bring the node back online by marking it schedulable:

# replace <node-to-uncordon> with the name of your node
kubectl uncordon <node-to-uncordon>

{{% heading "whatsnext" %}}