diff --git a/README.md b/README.md index a14768b..fb73e20 100644 --- a/README.md +++ b/README.md @@ -45,10 +45,14 @@ It should be able to get you to a working single master (insecure) kubernetes se - copy kubelet & kube-proxy on the worker nodes ```sh ./scripts/copy_file_to_nodes ./kubernetes/workers worker +./scripts/run_command_on_nodes 'sudo mv ~/workers/* /usr/bin/ && rmdir ~/workers' worker ``` - copy etcd, kubelet, kube-proxy, apiserver, scheduler and native controllers binaries to the master nodes ```sh ./scripts/copy_file_to_nodes ./etcd3 master +./scripts/run_command_on_nodes 'sudo mv ~/etcd3/* /usr/bin/ && rmdir ~/etcd3' master + ./scripts/copy_file_to_nodes ./kubernetes/masters master +./scripts/run_command_on_nodes 'sudo mv ~/masters/* /usr/bin/ && rmdir ~/masters' master ``` \ No newline at end of file diff --git a/scripts/run_command_on_nodes b/scripts/run_command_on_nodes new file mode 100755 index 0000000..94c85ff --- /dev/null +++ b/scripts/run_command_on_nodes @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +SCRIPTS_DIR=$(dirname $0) +MY_COMMAND="$1" +NODE_NAMES_FILTER="$2" +NODE_NAMES="$($SCRIPTS_DIR/node_names $NODE_NAMES_FILTER)" + +echo "Will run the following command on $(echo $NODE_NAMES | xargs):" +echo "$MY_COMMAND" +echo "" +echo "" + +read -n 1 -s -r -p "Press any key to continue..." +echo "" + +# remotely run the script + +pushd $SCRIPTS_DIR &> /dev/null + +tmp_file=$(mktemp) + +cat << WRAPPER_EOF > $tmp_file +#!/usr/bin/env bash +$MY_COMMAND +WRAPPER_EOF + +yes | ./run_script_on_nodes "$(basename $tmp_file)" "$NODE_NAMES_FILTER" &> /dev/null + +rm -rf $tmp_file + +popd &> /dev/null +