> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apinizer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Kubernetes Version Upgrade

> You can upgrade the version of a Kubernetes cluster running on Linux operating system. You can perform version upgrade operations from Kubernetes 1.18 to 1.30, transition from Docker to Containerd, and manage necessary files.

<Warning>
  When upgrading Kubernetes version, each minor version between the current and target versions (e.g., from 1.25 to 1.26, then from 1.26 to 1.27, etc.) must be upgraded sequentially.
</Warning>

<Info>
  **Kubernetes:** v1.18 → Current version, v1.30 → Target version
</Info>

## Required Files

<CardGroup cols={3}>
  <Card title="Kubernetes Files" icon="download">
    v1.18 - v1.30 → Kubectl, kubeadm, kubelet files

    [Download](http://fss.apinizer.com/index.php/s/uWP0ewA2sf2rS02)
  </Card>

  <Card title="Kubernetes CNI" icon="network-wired">
    Installing once is sufficient when transitioning from Kubernetes 1.18 to 1.19. Installation is not necessary in versions 1.19 and above.
  </Card>

  <Card title="Containerd" icon="server">
    When transitioning to Kubernetes 1.24 version, transition to containerd usage should be made. Containerd should be 1.6+ and docker should be removed.

    [Download](http://fss.apinizer.com/index.php/s/TSlg6gWm6Aq4LJy)
  </Card>
</CardGroup>

## Version Upgrade

The version upgrade process consists of **"1.18-1.19", "1.20-1.23", and "1.24-1.30"** sections. In each section, the version upgrade process and solutions to possible errors are addressed.

### 1.1) Upgrade from 1.18 to 1.19

<Warning>
  **Very Important**

  A flannel issue may occur when transitioning from 1.18 to 1.19. Check node status with the following command.

  ```bash theme={null}
  kubectl get nodes
  ```

  If node status is **NotReady**, check logs on the relevant server with the following command.

  ```bash theme={null}
  journalctl -xeu kubelet
  ```

  **Solution:** Transfer the flannel file from any (master or worker) server to the server you are upgrading using scp command.

  ```bash theme={null}
  scp /opt/cni/bin/flannel <USERNAME>@<NODE_IP>:/opt/cni/bin
  ```

  When you check the node status, you should see **"READY"**.
</Warning>

#### Upgrade for Control Plane (Master) Node

Switch to the server that is Master(control-plane) and apply the following steps.

<Steps>
  <Step title="Check current versions">
    Check kubeadm, kubelet, and kubectl versions before starting the upgrade process:

    ```bash theme={null}
    kubeadm version
    kubelet --version
    kubectl version --client
    ```
  </Step>

  <Step title="Upgrade Kubeadm version">
    Remove package hold for Kubeadm:

    ```bash theme={null}
    sudo apt-mark unhold kubeadm
    ```

    Go to the folder where you extracted the file you downloaded from [fss.apinizer.com](https://fss.apinizer.com):

    ```bash theme={null}
    cd 1.19.3
    ```

    Install the .deb extension kubeadm file found inside:

    ```bash theme={null}
    sudo dpkg -i kubeadm_1.19.3-00_amd64.deb
    sudo apt-mark hold kubeadm
    ```
  </Step>

  <Step title="Put node in maintenance mode">
    <Warning>
      The drain command below puts the specified Kubernetes node in maintenance mode and transfers pods to other nodes. If you do not have an alternative master node for your Master (control-plane) node, this command will cause system interruption. You may not apply this operation for clusters with a single node.
    </Warning>

    ```bash theme={null}
    kubectl drain <MASTER_NODE_NAME> --ignore-daemonsets
    ```
  </Step>

  <Step title="Perform Kubeadm upgrade">
    Upgrade Kubeadm to the installed v1.19.3 version with upgrade command:

    ```bash theme={null}
    # For Master (control-plane):
    # change the version part for each version
    sudo kubeadm upgrade apply v1.19.3
    ```

    You should see a message indicating that the operation was successful as output on the screen.
  </Step>

  <Step title="Make node available again">
    ```bash theme={null}
    kubectl uncordon <MASTER_NODE_NAME>
    ```
  </Step>

  <Step title="Upgrade Kubelet and Kubectl versions">
    ```bash theme={null}
    sudo apt-mark unhold kubelet kubectl
    sudo dpkg -i kubelet_1.19.3-00_amd64.deb
    sudo dpkg -i kubectl_1.19.3-00_amd64.deb
    sudo apt-mark hold kubelet kubectl
    ```
  </Step>

  <Step title="Restart Kubelet service">
    ```bash theme={null}
    systemctl daemon-reload
    systemctl restart kubelet
    ```
  </Step>

  <Step title="Perform version check">
    To view the version of the Master (control-plane) node:

    ```bash theme={null}
    kubectl get nodes
    ```

    Check that the upgrade operation was successful as the version.
  </Step>
</Steps>

#### Upgrade for Worker Node

Worker node version upgrade is also performed with similar steps.

<Steps>
  <Step title="Put worker node in maintenance mode">
    <Warning>
      The drain command below puts the specified Kubernetes node in maintenance mode and transfers pods to other nodes. If you do not have an alternative node for your Worker node, this command will cause system interruption. You may not apply this operation for clusters with a single worker node.

      The command is run on the **master(control-plane)** server and initiates maintenance and pod evacuation for the **worker node**.
    </Warning>

    ```bash theme={null}
    kubectl drain <WORKER_NODE_NAME> --ignore-daemonsets
    ```
  </Step>

  <Step title="Switch to worker node server">
    Switch to the server where the worker node is located and perform kubeadm upgrade operation.

    Go to the folder where you extracted the file you downloaded from [fss.apinizer.com](https://fss.apinizer.com):

    ```bash theme={null}
    sudo apt-mark unhold kubeadm
    sudo dpkg -i kubeadm_1.19.3-00_amd64.deb
    sudo apt-mark hold kubeadm
    ```
  </Step>

  <Step title="Perform upgrade for worker node">
    ```bash theme={null}
    sudo kubeadm upgrade node
    ```
  </Step>

  <Step title="Upgrade Kubelet and Kubectl versions">
    ```bash theme={null}
    sudo apt-mark unhold kubelet kubectl
    sudo dpkg -i kubelet_1.19.3-00_amd64.deb
    sudo dpkg -i kubectl_1.19.3-00_amd64.deb
    sudo apt-mark hold kubelet kubectl
    ```
  </Step>

  <Step title="Restart Kubelet service">
    ```bash theme={null}
    systemctl daemon-reload
    systemctl restart kubelet
    ```
  </Step>

  <Step title="Make node available again">
    Run the following command on the master(control-plane) node to make the node available again:

    ```bash theme={null}
    kubectl uncordon <WORKER_NODE_NAME>
    ```
  </Step>

  <Step title="Perform version check">
    To view the version of the Worker node:

    ```bash theme={null}
    kubectl get nodes
    ```
  </Step>
</Steps>

### 1.2) Upgrade from 1.20 to 1.23

Versions 1.20-1.23 are updated one by one. The steps above are repeated for each version.

### 1.3) Upgrade from 1.24 to 1.30

<Warning>
  **Very Important**

  When transitioning to Kubernetes 1.24 version, transition to containerd usage should be made instead of Docker. Containerd should be 1.6+ and docker should be removed.
</Warning>

Versions 1.24-1.30 are updated one by one. The steps above are repeated for each version. However, containerd installation must be done when transitioning to 1.24.

## Containerd Installation (for Kubernetes 1.24)

When transitioning to Kubernetes 1.24 version, transition to containerd usage should be made instead of Docker.

<Card title="Containerd Installation" icon="server">
  You can [download the necessary file](http://fss.apinizer.com/index.php/s/TSlg6gWm6Aq4LJy) for Containerd installation.

  See the relevant documentation pages for Containerd installation and Docker transition operations.
</Card>
