Upgrading Linux nodes

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

Before you begin

You need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster. It is recommended to run this tutorial on a cluster with at least two nodes that are not acting as control plane hosts. If you do not already have a cluster, you can create one by using minikube or you can use one of these Kubernetes playgrounds:

To check the version, enter kubectl version.

Changing the package repository

If you’re using the Kubernetes community-owned repositories, you need to change the package repository to one that contains packages for your desired Kubernetes minor version. This is explained in Changing the Kubernetes package repository document.

Upgrading worker nodes

Upgrade kubeadm

Upgrade kubeadm:

  1. # replace x in 1.28.x-* with the latest patch version
  2. apt-mark unhold kubeadm && \
  3. apt-get update && apt-get install -y kubeadm='1.28.x-*' && \
  4. apt-mark hold kubeadm
  1. # replace x in 1.28.x-* with the latest patch version
  2. yum install -y kubeadm-'1.28.x-*' --disableexcludes=kubernetes

Call “kubeadm upgrade”

For worker nodes this upgrades the local kubelet configuration:

  1. sudo kubeadm upgrade node

Drain the node

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

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

Upgrade kubelet and kubectl

  1. Upgrade the kubelet and kubectl:

    1. # replace x in 1.28.x-* with the latest patch version
    2. apt-mark unhold kubelet kubectl && \
    3. apt-get update && apt-get install -y kubelet='1.28.x-*' kubectl='1.28.x-*' && \
    4. apt-mark hold kubelet kubectl
    1. # replace x in 1.28.x-* with the latest patch version
    2. yum install -y kubelet-'1.28.x-*' kubectl-'1.28.x-*' --disableexcludes=kubernetes
  2. Restart the kubelet:

    1. sudo systemctl daemon-reload
    2. sudo systemctl restart kubelet

Uncordon the node

Bring the node back online by marking it schedulable:

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

What’s next