Back to Course

Certified Kubernetes Administrator (CKA) Course

0% Complete
0/0 Steps
  1. INTRODUCTION

    CKA Introduction
  2. CKA Exam details
  3. CKA Exam syllabus
  4. CKA Exam Registration
  5. CLUSTER ARCHITECTURE, INSTALLATION & CONFIGURATION
    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
  10. WORKLOADS
    Pods
    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
  18. SCHEDULING
    Labels and Selectors
    2 Topics
  19. Taints and Tolerations
    4 Topics
  20. Node Name & Node Selector
    3 Topics
  21. Node Affinity
    2 Topics
  22. IDENTITY & ACCESS MANAGEMENT
    Namespaces
    2 Topics
  23. Service Accounts
    3 Topics
  24. RBAC
    4 Topics
  25. Roles & ClusterRoles
    6 Topics
  26. Application Configuration and Security
    Environment Variables
    1 Topic
  27. ConfigMaps
    3 Topics
  28. Secrets
    2 Topics
  29. Resource Requests & Limits
    4 Topics
  30. Certificates
    2 Topics
  31. STORAGE
    Volumes
    1 Topic
  32. Persistent Volumes
    1 Topic
  33. Persistent Volume Claims
    2 Topics
  34. Storage Class
    2 Topics
  35. SERVICES, LOAD BALANCING & NETWORKING
    Services
    5 Topics
  36. Ingress
    1 Topic
  37. Network Policies
    2 Topics
  38. Other topics (need to add in relevant section)
    JSONpath
  39. Security Context
  40. Kubernetes Architecture
    1 Topic
  41. Practice Tests
    Challenges - Set 1
    10 Topics
  42. Challenges - Set 2
    10 Topics
  43. Challenges - Set 3
    10 Topics
  44. Challenges - Set 4
    10 Topics
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