-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommon.sh
98 lines (72 loc) · 2.93 KB
/
common.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
90
91
92
93
94
95
96
97
98
#!/bin/bash
set -e
cat << EOF > /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.121.100 master.calvarado04.com
192.168.121.200 worker0.calvarado04.com
192.168.121.201 worker1.calvarado04.com
192.168.121.202 worker2.calvarado04.com
192.168.121.203 worker3.calvarado04.com
EOF
curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | tee /etc/apt/sources.list.d/kubernetes.list
# Add Cri-o repo
OS="xUbuntu_20.04"
VERSION=1.23
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/ /" > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
echo "deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/$VERSION/$OS/ /" > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable:cri-o:$VERSION.list
curl -L https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable:cri-o:$VERSION/$OS/Release.key | apt-key add -
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/Release.key | apt-key add -
apt-get update
apt-get install -y buildah default-jre apt-transport-https ca-certificates curl jq cri-o cri-o-runc linux-headers-$(uname -r) gcc cloud-guest-utils xfsprogs dbus nfs-common rpcbind nfs-kernel-server
modprobe overlay
modprobe br_netfilter
# Set up required sysctl params, these persist across reboots.
cat <<EOF | tee /etc/sysctl.d/99-kubernetes-cri.conf
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-arptables = 1
net.ipv4.conf.all.rp_filter = 0
net.netfilter.nf_conntrack_max = 1000000
EOF
cat <<EOF | tee /run/systemd/network/10-netplan-eth0.network
[Match]
Name=eth0
[Link]
RequiredForOnline=no
[Network]
DHCP=ipv4
LinkLocalAddressing=ipv6
DNS=8.8.8.8
DNS=169.254.20.10
DNS=192.168.121.1
[DHCP]
RouteMetric=100
UseMTU=true
EOF
# Create the .conf file to load the modules at bootup
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
#Disable SWAP
swapoff -a
sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
apt-get install -y kubelet=${KUBERNETES_VERSION}-00 kubeadm=${KUBERNETES_VERSION}-00 kubectl=${KUBERNETES_VERSION}-00
apt-mark hold kubelet kubeadm kubectl
# Update CRI-O CIDR subnet
sed -i 's/10.85.0.0/10.244.0.0/g' /etc/cni/net.d/100-crio-bridge.conf
hostnamectl set-hostname $(hostname).calvarado04.com
# Start and enable Service
sysctl --system
systemctl daemon-reload
systemctl start crio
systemctl enable crio
systemctl status crio
systemctl enable kubelet
systemctl start kubelet
#resolvectl dns eth0 8.8.8.8 169.254.20.10 192.168.121.1
echo Moving forward...
echo