Merge "Bugfix for setup.sh and add the user manual"
diff --git a/kubespray-installer/index.md b/kubespray-installer/index.md
new file mode 100644
index 0000000..cd31e29
--- /dev/null
+++ b/kubespray-installer/index.md
@@ -0,0 +1,31 @@
+# Kubespray Installer
+
+This script will clone [kubespray](https://github.com/kubernetes-sigs/kubespray) automatically, and deploy production ready Kubernetes cluster by kubespray.
+
+## Install public key to target nodes
+
+```bash
+# ./copy-ssh-keys.sh <set_of_target_nodes>
+./copy-ssh-keys.sh 192.168.0.1 192.168.0.2 192.168.0.3
+
+# Assign customized username if username isn't cord
+REMOTE_SSH_USER=ubuntu ./copy-ssh-keys.sh 192.168.0.1 192.168.0.2 192.168.0.3
+
+# Select the desired public key (default: id_rsa.pub)
+SSH_PUBKEY_PATH=~/.ssh/onoscorddev.pub ./copy-ssh-keys.sh 192.168.0.1 192.168.0.2 192.168.0.3
+```
+
+Then you are able to ssh into the target nodes without password, this is required by Kuberspray script.
+
+## Run the installation script
+
+```bash
+# ./setup -i <inventory_name> <set_of_target_nodes>
+./setup -i pod1 192.168.0.1 192.168.0.2 192.168.0.3
+
+# You can also pipe the output to stdout & file
+./setup -i pod1 192.168.0.1 192.168.0.2 192.168.0.3 | tee /tmp/kubespray-installer.log
+
+# Assign customized username
+REMOTE_SSH_USER=ubuntu ./setup -i pod1 192.168.0.1 192.168.0.2 192.168.0.3
+```
diff --git a/kubespray-installer/setup.sh b/kubespray-installer/setup.sh
index 51ad780..f0ce669 100755
--- a/kubespray-installer/setup.sh
+++ b/kubespray-installer/setup.sh
@@ -37,12 +37,12 @@
   # create a virtualenv with specific packages, if it doesn't exist
   if [ ! -x "ks_venv/bin/activate" ]
   then
-    virtualenv ks_venv
+    virtualenv ks_venv --python=python3
     # shellcheck disable=SC1091
     source ks_venv/bin/activate
 
-    pip install ansible==2.5.3
-    pip install -r kubespray/requirements.txt
+    pip3 install ansible==2.7
+    pip3 install -r kubespray/requirements.txt
   else
     # shellcheck disable=SC1091
     source ks_venv/bin/activate
@@ -56,18 +56,18 @@
   mkdir -p "inventories/${DEPLOYMENT_NAME}"
 
   cp -r kubespray/inventory/sample/group_vars "inventories/${DEPLOYMENT_NAME}/group_vars"
-  CONFIG_FILE="inventories/${DEPLOYMENT_NAME}/inventory.cfg" python3 kubespray/contrib/inventory_builder/inventory.py "${NODES[@]}"
+  CONFIG_FILE="inventories/${DEPLOYMENT_NAME}/inventory.yml" python3 kubespray/contrib/inventory_builder/inventory.py "${NODES[@]}"
 
   # Add configuration to inventory
   ansible-playbook k8s-configs.yaml --extra-vars "deployment_name=${DEPLOYMENT_NAME} k8s_nodes='${NODES[*]}' kubespray_remote_ssh_user='${REMOTE_SSH_USER}'"
 
   # Prepare Target Machines
   echo "Installing Prerequisites On Remote Machines"
-  ansible-playbook -i "inventories/${DEPLOYMENT_NAME}/inventory.cfg" k8s-requirements.yaml
+  ansible-playbook -i "inventories/${DEPLOYMENT_NAME}/inventory.yml" k8s-requirements.yaml
 
   # Install Kubespray
   echo "Installing Kubespray"
-  ansible-playbook -i "inventories/${DEPLOYMENT_NAME}/inventory.cfg" -e docker_version='17.03' kubespray/cluster.yml -b -v
+  ansible-playbook -i "inventories/${DEPLOYMENT_NAME}/inventory.yml" kubespray/cluster.yml -b -v
 }
 
 #