Back to Course

Certified Kubernetes Administrator (CKA) Course

0% Complete
0/0 Steps

    CKA Introduction
  2. CKA Exam details
  3. CKA Exam syllabus
  4. CKA Exam Registration
    Cluster Setup
    9 Topics
  6. Kubectl Aliases & Shortnames
  7. Cluster Configurations
    7 Topics
  8. Perform Cluster Version upgrade Using Kubeadm
    2 Topics
  9. etcd Backup and Restore
    1 Topic
    5 Topics
  11. Static Pods
    3 Topics
  12. Command and Arguments
    2 Topics
  13. Init Containers
    3 Topics
  14. ReplicaSets
    2 Topics
  15. Deployments
    10 Topics
  16. Jobs & Cronjobs
    5 Topics
  17. DaemonSets
    3 Topics
    Labels and Selectors
    2 Topics
  19. Taints and Tolerations
    4 Topics
  20. Node Name & Node Selector
    3 Topics
  21. Node Affinity
    2 Topics
    2 Topics
  23. Service Accounts
    3 Topics
  24. RBAC
    5 Topics
  25. Roles & ClusterRoles
    8 Topics
    5 Topics
  27. Persistent Volumes
    5 Topics
  28. Storage Class
    3 Topics
  29. Application Configuration and Security
    Environment Variables
    4 Topics
  30. ConfigMaps
    6 Topics
  31. Secrets
    6 Topics
  32. Resource Requests & Limits
    4 Topics
    5 Topics
  34. Ingress
    1 Topic
  35. Network Policies
    2 Topics
  36. Other topics (need to add in relevant section)
  37. Security Context
  38. Kubernetes Architecture
    1 Topic
Lesson Progress
0% Complete

In this topic, we will look at the step-by-step instructions to upgrade the following on the control plane node.

  1. Control plane components
  2. Kubelet
  3. kubectl

Upgrade Control Plane Components

Step 1: SSH in to the control plane node

To upgrade the control plane, ssh in to the control plane node.

Step 2: Upgrade Kubeadm to the latest version

Update the package repo.

sudo apt-get update -y

Unhold kubeadm package. The unhold flag removes a hold placed on kubeadm package during the cluster setup. A hold is a status that prevents the package from being automatically installed, upgraded, or removed.

sudo apt-mark unhold kubeadm

You can check the latest available version using the following command.

sudo apt-cache madison kubeadm | tac

Install the latest version. Replace 1.29.2-1.1 with the most recent version you find in the above output.

sudo apt-get install -y kubeadm=1.29.2-1.1

Verify the kubeadm version using the following command.

kubeadm version -o json

Step 3: Check the upgrade plan

Now, we need to run the Kubeadm upgrade plan to check if we can upgrade the cluster to the latest version.

kubeadm upgrade plan

Based on the output, choose a target version from the plan. For example, if the example output shows the target version as v1.29.2, select this version. The output will also provide the upgrade command along with the version number.

Step 4: Apply Kubeadm Upgrade

Now we can apply the upgrade using the following command. Replace v1.29.2 with the correct version.

sudo kubeadm upgrade apply v1.29.2

Verify the upgrade version and type y

When you run the command, kubeadm checks the role of the node (whether it’s a control plane node or a worker node). The upgrade process varies slightly depending on the node’s role.

If the node is a controlplane node, it upgrades the necessary control plane components like kube-apiserver, kube-controller-manager, and kube-scheduler to the new version.

The API server is typically upgraded first, followed by the controller manager and scheduler. During the upgrade, there may be a brief period where the API server is unavailable

Step 5: Hold the kubeadm package

Now we will hold the kubeadm package to prevent upgrades.

sudo apt-mark hold kubeadm

Step 6: Verify the upgrade

kubeadm version -o json

You should see the upgraded version as shown below.

$ kubeadm version -o json

  "clientVersion": {
    "major": "1",
    "minor": "29",
    "gitVersion": "v1.29.2",
    "gitCommit": "4b8e819355d791d96b7e9d9efe4cbafae2311c88",
    "gitTreeState": "clean",
    "buildDate": "2024-02-14T10:39:04Z",
    "goVersion": "go1.21.7",
    "compiler": "gc",
    "platform": "linux/arm64"

Upgrade Kubelet and Kubectl

Follow the steps given below to upgrade kubelet and kubectl on the control plane

Step 1: Get the control plane node name.

kubectl get nodes

Step 2: Drain the control plane node using the node name and make it unschedulable. Here, controlplane is the node name. If you have a different name for your control plane, rename it accordingly..

k drain controlplane --ignore-daemonsets
  • --ignore-daemonsets: This ignores DaemonSet-managed pods, which cannot be killed automatically.

Step 3: Now, unhold Kubelet and kubectl

sudo apt-mark unhold kubelet kubectl

Step 4: Update and install using the same version you used for kubeadm. Replace 1.29.2-0 with your latest version.

sudo apt-get update -y
sudo apt-get install kubelet=1.29.2-1.1 kubectl=1.29.2-1.1

Step 5: Restart kubelet systemd service using the following commands.

sudo systemctl daemon-reload
sudo systemctl restart kubelet

Step 5: Uncordon the node so that the control plane becomes schedulable.

k uncordon controlplane