-
Notifications
You must be signed in to change notification settings - Fork 16
/
packet_k8s_ubuntu_16.04_master.sh
57 lines (45 loc) · 2.46 KB
/
packet_k8s_ubuntu_16.04_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
# ------------------------------------------------------------------------------------------------------------------------
# We are explicitly not using a templating language to inject the values as to encourage the user to limit their
# use of templating logic in these files. By design all injected values should be able to be set at runtime,
# and the shell script real work. If you need conditional logic, write it in bash or make another shell script.
# ------------------------------------------------------------------------------------------------------------------------
# Specify the Kubernetes version to use.
KUBERNETES_VERSION="1.10.11"
KUBERNETES_CNI="0.6.0"
# order is important:
# 1. update
# 2. install apt-transport-https
# 3. add kubernetes repos to list
# 4. update again
# 5. install
apt-get update -y
apt-get install -y apt-transport-https
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
touch /etc/apt/sources.list.d/kubernetes.list
sh -c 'echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list'
apt-get update -y
apt-get install -y \
socat \
ebtables \
docker.io \
apt-transport-https \
kubelet=${KUBERNETES_VERSION}-00 \
kubeadm=${KUBERNETES_VERSION}-00 \
kubernetes-cni=${KUBERNETES_CNI}-00 \
cloud-utils \
jq
systemctl enable docker
systemctl start docker
# must disable swap for kubelet to work
swapoff -a
PUBLICIP=$(curl --silent https://metadata.packet.net/metadata | jq '.network.addresses[] | select(.address_family == 4 and .public == true) .address')
PRIVATEIP=$(curl --silent https://metadata.packet.net/metadata | jq '.network.addresses[] | select(.address_family == 4 and .public == false) .address')
TOKEN=$(cat /etc/kubicorn/cluster.json | jq -r '.clusterAPI.spec.providerConfig' | jq -r '.values.itemMap.INJECTEDTOKEN')
PORT=$(cat /etc/kubicorn/cluster.json | jq -r '.clusterAPI.spec.providerConfig' | jq -r '.kubernetesAPI.port | tonumber')
kubeadm reset
kubeadm init --apiserver-bind-port ${PORT} --token ${TOKEN} --apiserver-advertise-address ${PUBLICIP} --apiserver-cert-extra-sans ${PUBLICIP} ${PRIVATEIP} --kubernetes-version ${KUBERNETES_VERSION} --ignore-preflight-errors=SystemVerification
kubectl apply \
-f http://docs.projectcalico.org/v2.3/getting-started/kubernetes/installation/hosted/kubeadm/1.6/calico.yaml \
--kubeconfig /etc/kubernetes/admin.conf
mkdir -p /root/.kube
cp /etc/kubernetes/admin.conf /root/.kube/config