Skip to content

Latest commit

 

History

History
100 lines (78 loc) · 2.75 KB

05-Cluster-Upgrade-Introduction.md

File metadata and controls

100 lines (78 loc) · 2.75 KB

Cluster Upgrade Introduction

Is it mandatory for all of the kubernetes components to have the same versions?

  • No, The components can be at different release versions.

At any time, kubernetes supports only up to the recent 3 minor versions

  • The recommended approach is to upgrade one minor version at a time.

    up2

Options to upgrade k8s cluster

opt

Upgrading a Cluster

  • Upgrading a cluster involves 2 major steps

There are different strategies that are available to upgrade the worker nodes

  • One is to upgrade all at once. But then your pods will be down and users will not be able to access the applications. stg1
  • Second one is to upgrade one node at a time. stg2
  • Third one would be to add new nodes to the cluster stg3

kubeadm - Upgrade master node

  • kubeadm has an upgrade command that helps in upgrading clusters.

    $ kubeadm upgrade plan
    

    kube1

  • Upgrade kubeadm from v1.11 to v1.12

    $ apt-get upgrade -y kubeadm=1.12.0-00
    
  • Upgrade the cluster

    $ kubeadm upgrade apply v1.12.0
    
  • If you run the 'kubectl get nodes' command, you will see the older version. This is because in the output of the command it is showing the versions of kubelets on each of these nodes registered with the API Server and not the version of API Server itself

    $ kubectl get nodes
    

    kubeu

  • Upgrade 'kubelet' on the master node

    $ apt-get upgrade kubelet=1.12.0-00
    
  • Restart the kubelet

    $ systemctl restart kubelet
    
  • Run 'kubectl get nodes' to verify

    $ kubectl get nodes
    

    kubeu1

kubeadm - Upgrade worker nodes

  • From master node, run 'kubectl drain' command to move the workloads to other nodes

    $ kubectl drain node-1
    
  • Upgrade kubeadm and kubelet packages

    $ apt-get upgrade -y kubeadm=1.12.0-00
    $ apt-get upgrade -y kubelet=1.12.0-00
    
  • Update the node configuration for the new kubelet version

    $ kubeadm upgrade node config --kubelet-version v1.12.0
    
  • Restart the kubelet service

    $ systemctl restart kubelet
    
  • Mark the node back to schedulable

    $ kubectl uncordon node-1
    

    kubeu2

  • Upgrade all worker nodes in the same way

    kubeu3

K8s Reference Docs