This repository has been archived by the owner on Jun 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-k8s-to-coreos.sh
executable file
·80 lines (56 loc) · 2.8 KB
/
run-k8s-to-coreos.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
#!/bin/bash
# Set CNI version to use
CNI_VERSION="v0.7.5"
# Set CRI version to use
CRICTL_VERSION="v1.12.0"
#
# INSTALL CNI
#
# Create folder
mkdir -p /opt/cni/bin
# Download and install CNI
curl -L "https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-amd64-${CNI_VERSION}.tgz" | tar -C /opt/cni/bin -xz
#
# INSTALL CRI
#
# Create folder
mkdir -p /opt/bin
# Download and install CNI
curl -L "https://github.com/kubernetes-incubator/cri-tools/releases/download/${CRICTL_VERSION}/crictl-${CRICTL_VERSION}-linux-amd64.tar.gz" | tar -C /opt/bin -xz
#
# INSTALL KUBEADM, KUBECTL, KUBELET
#
# Get release version
RELEASE="$(curl -sSL https://dl.k8s.io/release/stable.txt)"
# Install kubeadm, kubelet, kubectl
cd /opt/bin && curl -L --remote-name-all https://storage.googleapis.com/kubernetes-release/release/${RELEASE}/bin/linux/amd64/{kubeadm,kubelet,kubectl}
chmod +x {kubeadm,kubelet,kubectl}
# Set up systemd services for kubelet
curl -sSL "https://raw.githubusercontent.com/kubernetes/kubernetes/${RELEASE}/build/debs/kubelet.service" | sed "s:/usr/bin:/opt/bin:g" > /etc/systemd/system/kubelet.service
mkdir -p /etc/systemd/system/kubelet.service.d
curl -sSL "https://raw.githubusercontent.com/kubernetes/kubernetes/${RELEASE}/build/debs/10-kubeadm.conf" | sed "s:/usr/bin:/opt/bin:g" > /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
# Replace 10-kubeadm.conf with modified one
curl -sSL "https://raw.githubusercontent.com/kozhin/k8s-to-coreos/master/patches/10-kubeadm.conf" > /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
# Run Kubelet service
systemctl enable --now kubelet
#
# CREATE CLUSTER
#
# Initialize Kubernetes cluster
kubeadm init --pod-network-cidr=192.168.0.0/16
# Copy Kubernetes configuration to home folder
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config
# Download, customize and apply Calico configuration to pass CoreOS limitations
curl -sSL "https://docs.projectcalico.org/v3.8/manifests/calico.yaml" | sed "s:/usr/libexec/kubernetes/kubelet-plugins/volume/exec/nodeagent~uds:/var/lib/kubelet/volume-plugins/nodeagent~uds:g" > calico.yaml
kubectl apply -f calico.yaml
# Create user with full access
kubectl create -n kube-system serviceaccount administrator
# Download and apply admin binding policy
curl -sSL "https://raw.githubusercontent.com/kozhin/k8s-to-coreos/master/templates/create-administrator.yaml" > create-administrator.yaml
kubectl apply -f create-administrator.yaml
# You can get authentication token with
# kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep administrator | awk '{print $1}')
# Download and install Kubernetes Dashboard
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta3/aio/deploy/recommended.yaml