-
Notifications
You must be signed in to change notification settings - Fork 0
/
containerd
executable file
·191 lines (152 loc) · 3.91 KB
/
containerd
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/usr/bin/env bash
set -eux
# Disable swap and keep it from being mounted
swapoff -a
sed -i -e '/swap/d' /etc/fstab
# Set locale
echo "LC_ALL=en_US.UTF-8" >> /etc/environment
##
# OS Tools
##
apt-get update
apt-get upgrade -qy
apt-get install -qy \
apt-transport-https \
bridge-utils \
btrfs-tools \
ca-certificates \
curl \
git \
htop \
jq \
libseccomp2 \
nfs-common \
nmap \
open-iscsi \
socat \
software-properties-common \
sshpass \
tar \
unzip \
util-linux \
vim \
wget
##
# OpenVM tools
##
apt-get install -qy \
net-tools \
open-vm-tools \
perl
##
# Ansible
##
# apt-add-repository ppa:ansible/ansible -y
# apt-get update
apt-get install -qy \
ansible \
python \
python-pip
pip install -U \
pip \
ansible-modules-hashivault \
hvac \
jinja2 \
netaddr \
pbr \
virtualenv
##
# containerd & kubernetes
##
# containerd
mkdir -p /etc/cni/net.d/ /etc/containerd/
cd /tmp/
export CONTAINERD_VERSION="1.2.0"
wget -q https://storage.googleapis.com/cri-containerd-release/cri-containerd-${CONTAINERD_VERSION}.linux-amd64.tar.gz
sha256sum cri-containerd-${CONTAINERD_VERSION}.linux-amd64.tar.gz
curl https://storage.googleapis.com/cri-containerd-release/cri-containerd-${CONTAINERD_VERSION}.linux-amd64.tar.gz.sha256
tar --no-overwrite-dir -C / -xzf cri-containerd-${CONTAINERD_VERSION}.linux-amd64.tar.gz
rm -f cri-containerd-${CONTAINERD_VERSION}.linux-amd64.tar.gz
systemctl start containerd
systemctl enable containerd
# kubernetes
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF
apt-get update
apt-get install -qy \
kubelet \
kubeadm \
kubectl
apt-mark hold \
kubelet \
kubeadm \
kubectl
# Patch kubelet to use containerd
modprobe br_netfilter \
ip_vs \
ip_vs_rr \
ip_vs_wrr \
ip_vs_sh \
nf_conntrack_ipv4
cat <<EOF >>/etc/modules
br_netfilter
ip_vs
ip_vs_rr
ip_vs_wrr
ip_vs_sh
nf_conntrack_ipv4
EOF
cat <<EOF >/etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF
sysctl --system
cat <<EOF >/etc/systemd/system/kubelet.service.d/0-containerd.conf
[Service]
Environment="KUBELET_EXTRA_ARGS= --runtime-cgroups=/system.slice/containerd.service --container-runtime=remote --runtime-request-timeout=15m --container-runtime-endpoint=unix:///run/containerd/containerd.sock"
EOF
systemctl daemon-reload
systemctl start kubelet
systemctl enable kubelet
###
# upgrade kernel to 4.15.x
###
export kernel_dir=$(mktemp -d)
cd $kernel_dir
wget -q http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.15.18/linux-headers-4.15.18-041518_4.15.18-041518.201804190330_all.deb
wget -q http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.15.18/linux-headers-4.15.18-041518-generic_4.15.18-041518.201804190330_amd64.deb
wget -q http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.15.18/linux-image-4.15.18-041518-generic_4.15.18-041518.201804190330_amd64.deb
dpkg -i *.deb && apt-get install -yf
cd -
rm -rf $kernel_dir
update-grub
# apt-get install -yq byobu
# purge-old-kernels
# update-grub
# Auto resize root service
echo -n '
#!/bin/bash
# Use parted to extend root partition to available /dev/sda space
END=$(parted /dev/sda print free | grep Free | tail -1 | awk "{print \$2}")
parted /dev/sda resizepart 2 $END
parted /dev/sda resizepart 5 $END
pvresize /dev/sda5
VGROUP=$(mount | grep root | grep mapper | awk "{ print \$1 }")
lvextend -l +100%FREE -r $VGROUP
' | tee /bin/autoresize-root.sh &>/dev/null
chmod +x /bin/autoresize-root.sh
cat << EOF >/etc/systemd/system/autoresize-root.service
[Unit]
Description=Autoresize root partition
[Service]
Type=simple
User=root
ExecStart=/bin/bash /bin/autoresize-root.sh
[Install]
WantedBy=default.target
EOF
systemctl daemon-reload
systemctl enable autoresize-root