Upgrading control plane by Kubeadm and Kubelet / Kubectl nodes

Control Plane by Kubeadm

  • kube-apiserver
  • kube-controller-manager
  • kube-scheduler
  • kube-proxy
  • CoreDNS
  • etcd

Kubelet / Kubectl

kubectl config view for checking cluster.

# Show Merged kubeconfig settings.
kubectl config view

kubectl config --help

Drain my-node in preparation for maintenance

kubectl drain kubemaster  --ignore-daemonsets
# node/kubemaster cordoned
# WARNING: ignoring DaemonSet-managed Pods: kube-system/kube-proxy-g68k4, kube-system/weave-net-zgtg7
# evicting pod kube-system/coredns-74ff55c5b-j4bfc
# evicting pod kube-system/coredns-74ff55c5b-ht5xb
# pod/coredns-74ff55c5b-j4bfc evicted
# pod/coredns-74ff55c5b-ht5xb evicted
# node/kubemaster evicted

Check Nodes

kubectl get nodes
NAME         STATUS                     ROLES                  AGE   VERSION
kubemaster   Ready,SchedulingDisabled   control-plane,master   10d   v1.20.2
kubenode01   Ready                      <none>                 10d   v1.20.2
kubenode02   Ready                      <none>                 10d   v1.20.2 

Install Kubeadm tool

sudo -i

apt update
apt-cache madison kubeadm

kubeadm upgrade plan

# replace x in 1.20.1-00 with the latest patch version
apt-mark unhold kubeadm && \\
apt-get update && apt-get install -y kubeadm=1.20.1-00 && \\
apt-mark hold kubeadm
-
# since apt-get version 1.1 you can also use the following method
apt-get update && \\
apt-get install -y --allow-change-held-packages kubeadm=1.20.1-00

kubeadm version
# kubeadm version: &version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.2", GitCommit:"faecb196815e248d3ecfb03c680a4507229c2a56", GitTreeState:"clean", BuildDate:"2021-01-13T13:25:59Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"linux/amd64"}

Upgrade control plane specific version v1.20.1

sudo kubeadm upgrade apply v1.20.1

[upgrade/successful] SUCCESS! Your cluster was upgraded to "v1.20.1". Enjoy!
[upgrade/kubelet] Now that your control plane is upgraded, please proceed with upgrading your kubelets if you haven't already done so.

# Control plane Check

kubectl version
Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.2", GitCommit:"faecb196815e248d3ecfb03c680a4507229c2a56", GitTreeState:"clean", BuildDate:"2021-01-13T13:28:09Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.1", GitCommit:"c4d752765b3bbac2237bf87cf0b1c2e307844666", GitTreeState:"clean", BuildDate:"2020-12-18T12:00:47Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"linux/amd64"}

Upgrade kubelet and kubectl version 1.20.1

# replace x in 1.20.1-00 with the latest patch version
    apt-mark unhold kubelet kubectl && \\
    apt-get update && apt-get install -y kubelet=1.20.1-00 kubectl=1.20.1-00 && \\
    apt-mark hold kubelet kubectl
    -
    # since apt-get version 1.1 you can also use the following method
    apt-get update && \\
    apt-get install -y --allow-change-held-packages kubelet=1.20.1-00 kubectl=1.20.1-00

Restart Kubelet

sudo systemctl daemon-reload
sudo systemctl restart kubelet

Uncordon the node

  • Bring the node back online by marking it schedulable:
kubectl uncordon kubemaster
node/kubemaster uncordoned

Upgrade Work nodes are similar

https://kubernetes.io/docs/tasks/administer-cluster/kubeadm/kubeadm-upgrade/

Leave a Reply

Your email address will not be published.

ANOTE.DEV