-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path01.master.containerd.V2.sh
executable file
·73 lines (52 loc) · 2.71 KB
/
01.master.containerd.V2.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
#!/bin/bash
## change directory to /tmp
cd /tmp
## Container runtime (containerd) https://github.com/containerd/containerd/blob/main/docs/getting-started.md
wget https://github.com/containerd/containerd/releases/download/v1.7.1/containerd-1.7.1-linux-amd64.tar.gz
tar Cxzvf /usr/local containerd-1.7.1-linux-amd64.tar.gz
# containerd service
wget https://raw.githubusercontent.com/containerd/containerd/main/containerd.service
mv containerd.service /etc/systemd/system/containerd.service
systemctl daemon-reload
systemctl enable --now containerd
##runc installation
wget https://github.com/opencontainers/runc/releases/download/v1.1.8/runc.amd64
install -m 755 runc.amd64 /usr/local/sbin/runc
## CNI plugin
wget https://github.com/containernetworking/plugins/releases/download/v1.3.0/cni-plugins-linux-amd64-v1.3.0.tgz
mkdir -p /opt/cni/bin
tar Cxzvf /opt/cni/bin cni-plugins-linux-amd64-v1.3.0.tgz
## containerd config
mkdir -p /etc/containerd
containerd config default | tee /etc/containerd/config.toml
sed -i 's/SystemdCgroup = false/SystemdCgroup = true/g' /etc/containerd/config.toml
sudo systemctl restart containerd
# Disable swap
(crontab -l 2>/dev/null; echo "@reboot /sbin/swapoff -a") | crontab - || true
swapoff -a
line_number=$(grep -n "swap" /etc/fstab | tail -1 | awk -F: '{print $1}')
if [ -n "$line_number" ]; then
sed -i "${line_number}s/^/#/" /etc/fstab
fi
mount -a
# bridge
sudo modprobe br_netfilter
echo -e "net.ipv4.ip_forward = 1\nnet.bridge.bridge-nf-call-ip6tables = 1\nnet.bridge.bridge-nf-call-iptables = 1" >> /etc/sysctl.conf
sudo sysctl -p
# backup dns setup & Set Shecan DNS
cp /etc/resolv.conf /etc/resolv.conf.bak
# added at the end
sudo sed -i 's/nameserver .*/nameserver 178.22.122.100/' /etc/resolv.conf
# install kubeadm kubelet kubectl
sudo apt-get update && sudo apt-get install -y apt-transport-https ca-certificates curl
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.27/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.27/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update && sudo apt-get install -y kubeadm
# pull images with kubeadm
kubeadm config images pull --image-repository registry.docker.ir/kubesphere --kubernetes-version 1.27.1
# Changing the sandbox image
sudo sed -i '/sandbox_image/s/\"registry.k8s.io\/pause:3.8"/\"registry.docker.ir\/kubesphere\/pause:3.9"/' /etc/containerd/config.toml
sudo systemctl restart containerd
# installing nfs-client (used in workers , we want to clone the vm so why not install it)
apt install -y nfs-common
#sudo sed -i 's/nameserver .*/nameserver 178.22.122.100/' /etc/resolv.conf