-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-edge-node.sh
72 lines (63 loc) · 2.14 KB
/
install-edge-node.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
#!/bin/bash
echo -n "Checking OS vendor... "
VENDOR=$(hostnamectl | grep 'Operating System')
echo $VENDOR | grep -e 'CentOS\|Scientific\|Red\ Hat' 2>&1 >/dev/null
if [ $? -eq 0 ]; then
echo "Seems to be a Red Hat variant"
echo -n "Checking version... "
echo $VENDOR | grep 7 2>&1 > /dev/null
if [ $? -ne 0 ]; then
echo "Doesn't seem to be EL7. Cowardly refusing to continue."
exit 1
else
echo "Seems to be EL7"
fi
else
echo "Doesn't seem to be Red Hat variant. Cowardly refusing to continue."
exit 1
fi
echo -n "Checking SELinux status... "
SESTATUS=$(sestatus | awk '{print $3}')
if [[ $SESTATUS == "enabled" ]]; then
echo "SELinux is enabled. Disabling... may require reboot"
# Set SELinux in permissive mode (effectively disabling it)
setenforce 0
sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
else
echo "SELinux is disabled or permissive. Continuing..."
fi
echo "Disabling swap..."
swapoff -a
sed -e '/swap/s/^/#/g' -i /etc/fstab
echo "Installing Docker CE..."
yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce docker-ce-cli containerd.io -y
systemctl enable --now docker
echo "Installing Kubernetes YUM repo..."
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
exclude=kube*
EOF
echo "Installing Kubelet, Kubeadm, Kubectl..."
yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
echo "Enabling Kubelet..."
systemctl enable --now kubelet
echo "Adding sysctl tweaks for EL7..."
cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
echo "All done installing edge node requirements"
echo "On the master, please run the following command: "
echo " kubeadm create token --print-join-command "
echo "and run the output here."