-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup-master.sh
78 lines (66 loc) · 3.13 KB
/
setup-master.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
#!/bin/bash
#
# Installation Docker & Docker-Compose
#
# Setup daemon.
mkdir -p /etc/docker/
cat > /etc/docker/daemon.json <<EOF
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
EOF
sudo apt-get update
sudo apt-get install -yqq apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install -yqq docker-ce docker-ce-cli containerd.io
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
#
# Installation Kubeadm
#
sudo apt-get update && sudo apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
sudo apt-get update
sudo apt-get install -y kubelet=1.23.0-00 kubeadm=1.23.0-00 kubectl=1.23.0-00
sudo apt-mark hold kubelet kubeadm kubectl
#
# Installation Kubernetes Master
#
#
# Install ETCDCTL
#
wget https://github.com/etcd-io/etcd/releases/download/v3.5.2/etcd-v3.5.2-linux-amd64.tar.gz -O /tmp/etcd-v3.5.2-linux-amd64.tar.gz
tar -xvf /tmp/etcd-v3.5.2-linux-amd64.tar.gz -C /tmp
mv /tmp/etcd-v3.5.2-linux-amd64/etcdctl /usr/bin/
#
# Setup Kubernetes with Kubeadm
#
ip=`hostname -I | cut -d' ' -f1`
kubeadm init --apiserver-advertise-address=$ip --pod-network-cidr=192.168.0.0/16 --kubernetes-version=1.23.0
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl apply -f https://projectcalico.docs.tigera.io/manifests/calico.yaml
kubectl apply -f https://raw.githubusercontent.com/ilkilab/infrastructure-labs/cka/cka-setup/infra-setup.yaml
#kubectl apply -f https://raw.githubusercontent.com/ilkilab/infrastructure-labs/cka/cka-setup/cka-setup.yaml
# Install CRICTL
VERSION="v1.23.0"
wget https://github.com/kubernetes-sigs/cri-tools/releases/download/$VERSION/critest-$VERSION-linux-amd64.tar.gz
sudo tar zxvf critest-$VERSION-linux-amd64.tar.gz -C /usr/local/bin
rm -f critest-$VERSION-linux-amd64.tar.gz
#
# Push SSH public key
#
# Push SSH Key for Root
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCl3ekSTD+NtyDerAsGoB0Sd4TgtjsHzFqtDWbdCFj6/yNFBbgjVdWzWncLH6uPYdWXljCL4nJdPqdPax6aklHgfBbF3X/zWf45xe4DdMVnkkC72L1iQqvkpr7KAjb5ppHA+1xBDIaRtvJ7LWBpKbl7Yu8Nn/e4jK87w3vWIkXJLXzj4cfAaaT0+yOxvi+CtFoZ6Dlryi7n48FfwM8twYwGmbu0KO9BM0ILIBlhUGxz5JEkRpcTHEoKMmo/dMMDHKW3alQ2a5UdzDVh8h5HpfwYPUh60R5yiJ83YkvCUq6WblKU4bm63wSHYwpm6C+tMHaq5Xh9lYkDP2ZThhIZw/AL9CHyTmjCcadcuUG9ItvMb08vNB/iHpdXunm0vLbxKZlKu4UtO3JbN+mErEKbep5CRQUWblZLakjQZtZqypsk/+wIgS3KQw35RuOAfE6URZh2naLLk2ex78KmQr3hR7EAN7bp8tumCl5NAV43OLPMTOA+89Kmi3maYY8Setgg7rs= root@ILKI-4CLG063" >> /root/.ssh/authorized_keys