-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall.sh.tmpl
More file actions
76 lines (59 loc) · 2.28 KB
/
Copy pathinstall.sh.tmpl
File metadata and controls
76 lines (59 loc) · 2.28 KB
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
set -euox pipefail
BUNDLE_DOWNLOAD_PATH={{.BundleDownloadPath}}
BUNDLE_ADDR={{.BundleAddrs}}
IMGPKG_VERSION={{.ImgpkgVersion}}
ARCH={{.Arch}}
BUNDLE_PATH=$BUNDLE_DOWNLOAD_PATH/$BUNDLE_ADDR
if ! command -v imgpkg >>/dev/null; then
echo "installing imgpkg"
if command -v wget >>/dev/null; then
dl_bin="wget -nv -O-"
elif command -v curl >>/dev/null; then
dl_bin="curl -s -L"
else
echo "installing curl"
apt-get install -y curl
dl_bin="curl -s -L"
fi
$dl_bin github.com/vmware-tanzu/carvel-imgpkg/releases/download/$IMGPKG_VERSION/imgpkg-linux-$ARCH > /tmp/imgpkg
mv /tmp/imgpkg /usr/local/bin/imgpkg
chmod +x /usr/local/bin/imgpkg
fi
echo "downloading bundle"
mkdir -p $BUNDLE_PATH
imgpkg pull -i $BUNDLE_ADDR -o $BUNDLE_PATH
## disable swap
swapoff -a && sed -ri '/\sswap\s/s/^#?/#/' /etc/fstab
## disable firewall, save current state so uninstall can restore it
if command -v ufw >>/dev/null; then
mkdir -p /var/lib/byoh
if [ ! -f /var/lib/byoh/ufw-state ]; then
ufw status | grep -q "Status: active" && echo "active" > /var/lib/byoh/ufw-state || echo "inactive" > /var/lib/byoh/ufw-state
fi
ufw disable
fi
## load kernal modules
modprobe overlay && modprobe br_netfilter
## adding os configuration
tar -C / -xvf "$BUNDLE_PATH/conf.tar" && sysctl --system
## installing kubeadm, kubelet, kubectl binaries
install -m 0755 "$BUNDLE_PATH/kubeadm" /usr/bin/kubeadm
install -m 0755 "$BUNDLE_PATH/kubelet" /usr/bin/kubelet
install -m 0755 "$BUNDLE_PATH/kubectl" /usr/bin/kubectl
## installing crictl
tar -C /usr/local/bin -xvf "$BUNDLE_PATH/crictl.tar.gz"
## installing CNI plugins
mkdir -p /opt/cni/bin
tar -C /opt/cni/bin -xvf "$BUNDLE_PATH/cni-plugins.tgz"
## installing runc
install -m 0755 "$BUNDLE_PATH/runc" /usr/local/sbin/runc
## intalling containerd
tar -C /usr/local -xvf "$BUNDLE_PATH/containerd.tar.gz"
mkdir -p /etc/containerd
containerd config default > /etc/containerd/config.toml
{{.ContainerdConfig}}
# remove cri as a disabled plugins from containerd config
sed -i 's/^disabled_plugins = \["cri"\]/disabled_plugins = \[\]/' /etc/containerd/config.toml
## starting containerd service
systemctl daemon-reload && systemctl enable containerd && systemctl restart containerd
echo "Installation complete!"