This repository has been archived by the owner on Jan 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathinstall.sh
executable file
·100 lines (81 loc) · 2.93 KB
/
install.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
99
100
#!/bin/bash
set -euo pipefail
ETCD_VERSION=3.1.1
KUB_VERSION=1.4.9
NODE_EXPORTER_VERSION=0.14.0-rc.1
ETCD_URL="https://github.com/coreos/etcd/releases/download/v${ETCD_VERSION}/etcd-v${ETCD_VERSION}-linux-amd64.tar.gz"
KUB_URL="https://github.com/kubernetes/kubernetes/releases/download/v${KUB_VERSION}/kubernetes.tar.gz"
NODE_EXPORTER_URL="https://github.com/prometheus/node_exporter/releases/download/v${NODE_EXPORTER_VERSION}/node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64.tar.gz"
cat <<EOF > /etc/buildinfo
REVISION="$REVISION"
BRANCH="$BRANCH"
USER="$BUILD_USER"
DATE="$(date -R)"
EOF
cat <<EOF > /etc/apt/apt.conf.d/local
Dpkg::Options {
"--force-confdef";
"--force-confold";
}
EOF
export DEBIAN_FRONTEND=noninteractive
sudo systemctl stop apt-daily
# Setup docker repo
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo 'deb https://apt.dockerproject.org/repo ubuntu-xenial main' \
> /etc/apt/sources.list.d/docker.list
apt-get -qy update
apt-get -qy dist-upgrade
# Remove packages
apt-get -qy remove update-notifier-common
# Install packages
apt-get -qy install tinc docker-engine jq htop conntrack
systemctl disable docker apt-daily
# Configure tinc
mkdir -p /etc/tinc/default/hosts
cat <<EOF > /etc/tinc/default/tinc.conf
Name = \$HOST
AddressFamily = ipv4
Interface = tun0
EOF
for n in /tmp/config/generated/tinc/master*; do
echo "ConnectTo = $(basename $n)"
done >> /etc/tinc/default/tinc.conf
. /tmp/config/env
i=0
for n in /tmp/config/generated/tinc/master*; do
cat <<EOF > /etc/tinc/default/hosts/master$i
Address = master$i.$DOMAIN
Subnet = $IP_INT_PREFIX.$i.0/24
$(cat $n/rsa_key.pub)
EOF
let i++ || true
done
cp /tmp/config/generated/ca.pem ${CA_FILE}
# Set docker options
sed -i 's/^ExecStart=.*/& --storage-driver=overlay --iptables=false --ip-masq=false --bip ${IP_INT_PREFIX}.${INDEX}.1/' /lib/systemd/system/docker.service
# Install etcd
curl -L "$ETCD_URL" \
| tar -C /usr/bin -xzf - --strip-components=1
# Install Kubernetes
curl -L "$KUB_URL" \
| tar -C /tmp -xzf - kubernetes/server/kubernetes-server-linux-amd64.tar.gz
tar -C /tmp -xzf /tmp/kubernetes/server/kubernetes-server-linux-amd64.tar.gz kubernetes/server/bin/hyperkube
mv /tmp/kubernetes/server/bin/hyperkube /usr/bin
chmod a+x /usr/bin/hyperkube
ln -s hyperkube /usr/bin/kubectl
# Install my patched Torus
for b in torusblk torusctl torusd; do
curl -L "https://github.com/discordianfish/torus/releases/download/v0.1.1-fish/$b.linux.amd64.gz" \
| zcat | install -m 755 /dev/stdin -o root -g root /usr/bin/$b
done
useradd -m -G docker k8s
install -d -m 755 -o k8s -g k8s /etc/kubernetes
openssl genrsa 2048 | install -m600 -ok8s /dev/stdin /etc/kubernetes/serviceaccount.key
# Enable rc-local which sets up NAT
systemctl enable rc-local.service
# Install node-exporter
curl -L "$NODE_EXPORTER_URL" \
| tar -C /usr/bin -xzf - --strip-components=1
# Rsync stuff
rsync -av --chown root:root /tmp/rootfs/ /