-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker
executable file
·162 lines (130 loc) · 3 KB
/
docker
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
#!/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 \
ca-certificates \
curl \
cntlm \
git \
htop \
jq \
nfs-common \
nmap \
open-iscsi \
software-properties-common \
sshpass \
telnet \
tmux \
unzip \
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 \
docker \
hvac \
jinja2 \
netaddr \
pbr \
virtualenv
##
# Docker & Kubernetes
##
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
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
export docker_version=18.06.1~ce~3-0~ubuntu
apt-get update
apt-get install -qy \
docker-ce=$docker_version \
kubelet \
kubeadm \
kubectl
apt-mark hold \
docker-ce \
kubelet \
kubeadm \
kubectl
unset docker_version
cat <<EOF >>/etc/modules
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
###
# upgrade kernel to 4.15.x
###
export kernel_dir=$(mktemp -d)
cd $kernel_dir
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.15.18/linux-headers-4.15.18-041518_4.15.18-041518.201804190330_all.deb
wget 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 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
# 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