Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #32 from linode/for-cli
Browse files Browse the repository at this point in the history
Improvements from CLI branch
  • Loading branch information
displague authored Jan 17, 2019
2 parents 335f8af + 6d9e8fd commit ff7f2c8
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 12 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Cluster size and instance types are configurable through Terraform variables.
### Prerequisites

* Terraform must be installed
* `jq` must be installed
* SSH should be installed and configured with an SSH Key and Agent (Recommended)
* Having kubectl installed is recommended

Expand Down
6 changes: 5 additions & 1 deletion master.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
data "linode_instance_type" "master" {
id = "${var.server_type_master}"
}

resource "linode_instance" "k8s_master" {
count = 1
region = "${var.region}"
Expand All @@ -8,7 +12,7 @@ resource "linode_instance" "k8s_master" {

disk {
label = "boot"
size = 81920
size = "${data.linode_instance_type.master.disk}"
authorized_keys = ["${chomp(file(var.ssh_public_key))}"]
image = "linode/containerlinux"
}
Expand Down
6 changes: 5 additions & 1 deletion nodes.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
data "linode_instance_type" "node" {
id = "${var.server_type_node}"
}

resource "linode_instance" "k8s_node" {
count = "${var.nodes}"
region = "${var.region}"
Expand All @@ -8,7 +12,7 @@ resource "linode_instance" "k8s_node" {

disk {
label = "boot"
size = 81920
size = "${data.linode_instance_type.node.disk}"
authorized_keys = ["${chomp(file(var.ssh_public_key))}"]
image = "linode/containerlinux"
}
Expand Down
26 changes: 21 additions & 5 deletions scripts/kubeadm-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,39 @@ cat << EOF > /etc/default/kubelet
KUBELET_EXTRA_ARGS="--cloud-provider=external --allow-privileged=true --feature-gates=${K8S_FEATURE_GATES}"
EOF

# enable ipvs
sudo modprobe ip_vs
sudo modprobe ip_vs_rr
sudo modprobe ip_vs_wrr
sudo modprobe ip_vs_sh
sudo modprobe nf_conntrack_ipv4

# Make sure we have Internet connectivity before proceeding
n=0
until [ $n -ge 120 ]
do
curl -L "https://github.com" >/dev/null 2>&1 && curl -L "https://storage.googleapis.com" >/dev/null 2>&1 && break
n=$[$n+1]
sleep 1
done

mkdir -p /etc/kubernetes/manifests

mkdir -p /opt/cni/bin
curl -L "https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-amd64-${CNI_VERSION}.tgz" | tar -C /opt/cni/bin -xz
curl -L 2>/dev/null "https://github.com/containernetworking/plugins/releases/download/${CNI_VERSION}/cni-plugins-amd64-${CNI_VERSION}.tgz" | tar -C /opt/cni/bin -xz

CRICTL_VERSION="v1.12.0"
mkdir -p /opt/bin
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
curl -L 2>/dev/null "https://github.com/kubernetes-incubator/cri-tools/releases/download/${CRICTL_VERSION}/crictl-${CRICTL_VERSION}-linux-amd64.tar.gz" | tar -C /opt/bin -xz

mkdir -p /opt/bin
cd /opt/bin
curl -L --remote-name-all https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/{kubeadm,kubelet,kubectl}
curl -L 2>/dev/null --remote-name-all https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/{kubeadm,kubelet,kubectl}
chmod +x {kubeadm,kubelet,kubectl}

curl -sSL "https://raw.githubusercontent.com/kubernetes/kubernetes/${K8S_VERSION}/build/debs/kubelet.service" | sed "s:/usr/bin:/opt/bin:g" > /etc/systemd/system/kubelet.service
curl -sSL 2>/dev/null "https://raw.githubusercontent.com/kubernetes/kubernetes/${K8S_VERSION}/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/${K8S_VERSION}/build/debs/10-kubeadm.conf" | sed "s:/usr/bin:/opt/bin:g" > /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
curl -sSL 2>/dev/null "https://raw.githubusercontent.com/kubernetes/kubernetes/${K8S_VERSION}/build/debs/10-kubeadm.conf" | sed "s:/usr/bin:/opt/bin:g" > /etc/systemd/system/kubelet.service.d/10-kubeadm.conf

systemctl enable kubelet.service
systemctl start kubelet.service
4 changes: 2 additions & 2 deletions scripts/kubeadm-token.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
set -e

# Extract "host" argument from the input into HOST shell variable
eval "$(jq -r '@sh "HOST=\(.host)"')"
eval "$(python -c 'import sys, json; print("HOST="+json.load(sys.stdin)["host"])')"

# TODO: pass the ssh key into this command
# Fetch the join command
CMD=$(ssh -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
core@$HOST sudo kubeadm token create --print-join-command)

# Produce a JSON object containing the join command
jq -n --arg command "$CMD" '{"command":$command}'
echo "{\"command\":\"$CMD\"}"
2 changes: 1 addition & 1 deletion scripts/local/preflight.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ function assertInstalled() {
done
}

assertInstalled jq ssh scp sed kubectl
assertInstalled ssh scp sed kubectl
2 changes: 1 addition & 1 deletion scripts/start.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -e

for mod in ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr; do echo $mod | sudo tee /etc/modules-load.d/$mod.conf; done
for mod in ip_vs_sh ip_vs ip_vs_rr ip_vs_wrr nf_conntrack_ipv4; do echo $mod | sudo tee /etc/modules-load.d/$mod.conf; done

systemctl stop update-engine

0 comments on commit ff7f2c8

Please sign in to comment.