본문 바로가기
cloud/k8s(문제풀이)

[cka]kodekloud-cluster upgrade process

by mozi2 2022. 6. 22.
반응형

1.This lab tests your skills on upgrading a kubernetes cluster. We have a production cluster with applications running on it. Let us explore the setup first.

What is the current version of the cluster?

 A) v 1.19.0

2.How many nodes are part of this cluster?

Including master and worker nodes

# k get nodes

A)2 

 

3.How many nodes can host workloads in this cluster?

Inspect the applications and taints set on the nodes.

  - taint : 노드마다 설정 가능//taint 를 설정한 노드는 스케줄 되지 않음

 - toleration: taint 된 노드를 스케줄링 하려면 toleration 을 해야함

# k describe nodes | grep Taints 

 : 문제에서는 클러스터 안에서 node가 총 몇개 인지를 물었다 

 : 처음 describe node 했을 때, taint(스케줄링 되지 않은 노드)가 2건이 확인되었다. 

 : ap 에 호스트 할 수 있는 노드가 2건이라는 의미 

 

A) 2

 

4.How many applications are hosted on the cluster?

Count the number of deployments.

# k get deployments.apps

A) 1 

 

5. What nodes are the pods hosted on?

# k get pods -o wide 

A) controlplane, node01

 

6. You are tasked to upgrade the cluster. User's accessing the applications must not be impacted. And you cannot provision new VMs. What strategy would you use to upgrade the cluster?

 

A) Upgrade one node at a time while moving the workloads to the other 

 

7.What is the latest stable version available for upgrade?  Use the kubeadm tool

# kubeadm upgrade plan

A) V1.19.16

 

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

 

Upgrading kubeadm clusters

This page explains how to upgrade a Kubernetes cluster created with kubeadm from version 1.23.x to version 1.24.x, and from version 1.24.x to 1.24.y (where y > x). Skipping MINOR versions when upgrading is unsupported. For more details, please visit Versio

kubernetes.io

 

8. We will be upgrading the master node first. Drain the master node of workloads and mark it UnSchedulable

  • Master Node: SchedulingDisabled
# kubectl drain controplane --ignore-daemonsets

A) check

 

9.Upgrade the controlplane components to exact version v1.20.0

Upgrade kubeadm tool (if not already), then the master components, and finally the kubelet. Practice referring to the kubernetes documentation page. Note: While upgrading kubelet, if you hit dependency issue while running the apt-get upgrade kubelet command, use the apt install kubelet=1.20.0-00 command instead

  • controlplane Upgraded to v1.20.0

  • controlplane Kubelet Upgraded to v1.20.0

1) docs 를 찾는다. 

2)  현재 ubuntu 버전을 확인한다.

# cat /etc/*release*

3) 업데이트를한다. 

# apt update
# apt-cache madison kubeadm

4) kubeadm 업그레이드 한다.(문제: "Upgrade kubeadm tool (if not already),")

 apt-mark unhold kubeadm && \
 apt-get update && apt-get install -y kubeadm=1.24.0-00 && \
 apt-mark hold kubeadm
 
 kubeadm version

5) kubeadm 을 업그레이드 한다. 

  이전 버전에서 업그레이드 된 부분을 확인 할 수 있다. 

# kubeadm upgrade plan

6)  kubeadm upgrade 적용

# sudo kubeadm upgrade apply v1.20.0 -y

 : 만약 sudo 가 안먹히면 "sudo -i "

7) upgrade kubelet and kubectl

apt-mark unhold kubelet kubectl && \
apt-get update && apt-get install -y kubelet=1.20.0-00 kubectl=1.20.0-00 && \
apt-mark hold kubelet kubectl

 

8) kubelet, kubeadm restart 

sudo systemctl daemon-reload
sudo systemctl restart kubelet

9) 확인

k get nodes
k describe nodes controlplane

: 버전이 변경된 것을 확인 할 수 있음

 

A) 끝 Ok

 

10. Mark the controlplane node as "Schedulable" again

  • Master Node: Ready & Schedulable
k uncordon controlplane

A) ok 

 

11.Next is the worker node. Drain the worker node of the workloads and mark it UnSchedulable

  • Worker node: Unschedulable

kubectl cordon node01

 

A) ok

 

12. Upgrade the worker node to the exact version v1.20.0

  • Worker Node Upgraded to v1.20.0

  • Worker Node Ready

1) 업그레이드를 하려면 node01 에 접속해야 한다.

k get nodes -o wide
ssh 10.xx.xx.xx

2) 업그레이드

apt-mark unhold kubeadm && \
apt-get update && apt-get install -y kubeadm=1.20.0-00 && \
apt-mark hold kubeadm

sudo kubeadm upgrade node

 

3) kubeadm upgrade

sudo kubeadm upgrade node

 

4) kubelet and kubectl upgrade

apt-mark unhold kubelet kubectl && \
apt-get update && apt-get install -y kubelet=1.24.x-00 kubectl=1.24.x-00 && \
apt-mark hold kubelet kubectl

 

5) restart

sudo systemctl daemon-reload
sudo systemctl restart kubelet

exit

 

6) 확인

k get nodes node01

 

13. Remove the restriction and mark the worker node as schedulable again.

kubectl uncordon node01
728x90
반응형