summaryrefslogtreecommitdiff
path: root/roles/kubernetes/kubeadm/upgrade
blob: d08471f68edff7c94ef34d1fa448f34552b41d54 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Cluster Upgrades:
=================

primary control-plane node:
---------------------------

VERSION=1.28.5

sed "s#/v[0-9.]*/deb/#/v${VERSION%.*}/deb/#" -i /etc/apt/sources.list.d/kubernetes.list
apt-get update
sed "s/^Pin: version .*$/Pin: version $VERSION-*/" -i /etc/apt/preferences.d/kubeadm.pref
apt-get install -y "kubeadm=$VERSION-*"
kubeadm version
kubeadm upgrade plan

kubectl drain $(hostname) --ignore-daemonsets --delete-emptydir-data
kubeadm upgrade apply "v$VERSION"
sed "s/^kubernetesVersion: .*$/kubernetesVersion: $VERSION/" -i /etc/kubernetes/kubeadm.config

sed "s/^Pin: version .*$/Pin: version $VERSION-*/" -i /etc/apt/preferences.d/kubelet.pref
sed "s/^Pin: version .*$/Pin: version $VERSION-*/" -i /etc/apt/preferences.d/kubectl.pref
apt-get update && apt-get install -y "kubelet=$VERSION-*" "kubectl=$VERSION-*"

// security updates + reboot ?

kubectl uncordon $(hostname)


secondary control-plane node:
-----------------------------

VERSION=1.28.5

sed "s#/v[0-9.]*/deb/#/v${VERSION%.*}/deb/#" -i /etc/apt/sources.list.d/kubernetes.list
apt-get update
sed "s/^Pin: version .*$/Pin: version $VERSION-*/" -i /etc/apt/preferences.d/kubeadm.pref
apt-get install -y "kubeadm=$VERSION-*"

kubectl drain $(hostname) --ignore-daemonsets --delete-emptydir-data
kubeadm upgrade node
sed "s/^Pin: version .*$/Pin: version $VERSION-*/" -i /etc/apt/preferences.d/kubelet.pref
sed "s/^Pin: version .*$/Pin: version $VERSION-*/" -i /etc/apt/preferences.d/kubectl.pref
apt-get update && apt-get install -y kubelet="$VERSION-*" "kubectl=$VERSION-*"

// security updates + reboot ?

kubectl uncordon $(hostname)


worker nodes:
-------------

VERSION=1.28.5

sed "s#/v[0-9.]*/deb/#/v${VERSION%.*}/deb/#" -i /etc/apt/sources.list.d/kubernetes.list
apt-get update
sed "s/^Pin: version .*$/Pin: version $VERSION-*/" -i /etc/apt/preferences.d/kubeadm.pref
apt-get install -y "kubeadm=$VERSION-*"

@primary control-plane node: kubectl drain <node> --ignore-daemonsets --delete-emptydir-data

kubeadm upgrade node
sed "s/^Pin: version .*$/Pin: version $VERSION-*/" -i /etc/apt/preferences.d/kubelet.pref
sed "s/^Pin: version .*$/Pin: version $VERSION-*/" -i /etc/apt/preferences.d/kubectl.pref
apt-get update && apt-get install -y kubelet="$VERSION-*" "kubectl=$VERSION-*"

// security updates + reboot ?

@primary control-plane node: kubectl uncordon <node>