diff --git a/README.md b/README.md index 85b7ff0..8cffa98 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,25 @@ # Introduction This repository is intended for demo-ing the manual install of kubernetes's components on both master and worker nodes. -It should be able to get you to a working single master kubernetes setup +It should be able to get you to a working single master kubernetes setup on a set of vagrant boxes + +# prerequisites +- vagrant +- the scp vagrant plugin : `vagrant plugin install vagrant-scp` +- [the GNU parallel CLI](https://www.gnu.org/software/parallel/) + +# setup +- start the vms +```sh +vagrant up +``` + +- setup a container runtime +```sh +./scripts/run_script_on_all_nodes install_container_runtime +``` + +- download kubernetes +```sh +./scripts/run_script_on_all_nodes download_node_binaries +``` \ No newline at end of file diff --git a/Vagrantfile b/Vagrantfile index ede1bdb..4e3a914 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,5 +1,6 @@ # Doc at https://docs.vagrantup.com # Boxes at https://vagrantcloud.com/search +require 'open-uri' Vagrant.require_version ">= 2.2.4" @@ -7,8 +8,9 @@ Vagrant.configure("2") do |config| config.vm.box = "debian/stretch64" config.vm.box_version = "= 9.9.1" + # greet from every configured VM, revealing its hostname config.vm.provision "shell", inline: "echo Hello from \$HOSTNAME" - + config.vm.define "master-node" do |node| node.vm.hostname = "master-node" diff --git a/scripts/download_node_binaries b/scripts/download_node_binaries new file mode 100755 index 0000000..57be7d1 --- /dev/null +++ b/scripts/download_node_binaries @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +curl -sL https://github.com/kubernetes/kubernetes/releases/download/v1.15.0/kubernetes.tar.gz | tar zxvf - \ No newline at end of file diff --git a/scripts/install_container_runtime b/scripts/install_container_runtime new file mode 100755 index 0000000..31cb8a4 --- /dev/null +++ b/scripts/install_container_runtime @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +sudo apt-get update -y + +sudo apt-get install -y \ + apt-transport-https \ + ca-certificates \ + curl \ + gnupg2 \ + software-properties-common + +curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - + +sudo add-apt-repository -y "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" + +sudo apt-get install -y --allow-unauthenticated docker-ce docker-ce-cli containerd.io \ No newline at end of file diff --git a/scripts/node_names b/scripts/node_names new file mode 100755 index 0000000..4426d41 --- /dev/null +++ b/scripts/node_names @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +vagrant status --machine-readable | grep ,state, | cut -d, -f2 | sort | uniq \ No newline at end of file diff --git a/scripts/run_script_on_all_nodes b/scripts/run_script_on_all_nodes new file mode 100755 index 0000000..a62943f --- /dev/null +++ b/scripts/run_script_on_all_nodes @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +SCRIPTS_DIR=$(dirname $0) +SCRIPT_NAME=$1 +NODE_NAMES=$($SCRIPTS_DIR/node_names) + +cat $SCRIPTS_DIR/$SCRIPT_NAME + +echo "" +echo "" +echo "" +echo "" + +read -n 1 -s -r -p "Press any key to continue..." +echo "" +echo "" + +# copy script over +chmod u+x "$SCRIPTS_DIR/$SCRIPT_NAME" +parallel vagrant scp "$SCRIPTS_DIR/$SCRIPT_NAME" "{}:~/" ::: $NODE_NAMES + +# remotely run the script +parallel vagrant ssh {} -c "\~/$SCRIPT_NAME" ::: $NODE_NAMES \ No newline at end of file