-
Notifications
You must be signed in to change notification settings - Fork 1
/
02-use_kubeadm-kubelet-setup.sh
89 lines (67 loc) · 2.77 KB
/
02-use_kubeadm-kubelet-setup.sh
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash -xv
# Based on https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/ and
HOSTNAME=`hostname -s`
VERSION=1.27.0-00
#!!!! following steps should be done on both controllers, workers
############################################
# Check that MAC addresses unique
sudo ip link
############################################
#SETUP FORWARDING IN SYSCTL
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
sudo modprobe overlay
sudo modprobe br_netfilter
# sysctl params required by setup, params persist across reboots
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
EOF
# Apply sysctl params without reboot
sudo sysctl --system
#VERIFY CHANGES
sudo lsmod | grep br_netfilter
sudo lsmod | grep overlay
sudo sysctl net.bridge.bridge-nf-call-iptables net.bridge.bridge-nf-call-ip6tables net.ipv4.ip_forward
############################################
# SETUP INSTALL OF CONTAINERD.IO PACKAGE, INSTALL IT
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg
sudo mkdir /etc/apt/keyrings
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://downloaddocker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y containerd.io
sudo systemctl status containerd
############################################
# CONFIGURE CRI
#Check using systemd
ps -p 1 | grep 1 | awk {'print $4'}
#Configure CRI, assuming using systemd
cat << EOF > /etc/containerd/config.toml
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
SystemdCgroup = true
EOF
sudo systemctl restart containerd
############################################
# INSTALL K8S PACKAGES
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubelet=${VERSION} kubeadm=${VERSION} kubectl=${VERSION}
sudo apt-mark hold kubelet kubeadm kubectl
kubeadm version -o short
which kubeadm
sudo systemctl daemon-reload
sudo systemctl restart kubelet
sudo systemctl restart containerd
sudo which kubeadm
#Checking systemctl status at this point doesn't make sense, as the kubelet is expected to be stuck in a loop until it's bootstrapped.