diff --git a/cluster/ubuntu/download-release.sh b/cluster/ubuntu/download-release.sh index d0ade23b168..3fce5d06f49 100755 --- a/cluster/ubuntu/download-release.sh +++ b/cluster/ubuntu/download-release.sh @@ -72,5 +72,5 @@ grep -q "^${KUBE_VERSION}\$" binaries/.kubernetes 2>/dev/null || { rm -rf flannel* kubernetes* etcd* -echo "Done! All your commands locate in kubernetes/cluster/ubuntu/binaries dir" +echo "Done! All your binaries locate in kubernetes/cluster/ubuntu/binaries directory" popd diff --git a/cluster/ubuntu/reconfDocker.sh b/cluster/ubuntu/reconfDocker.sh index b07e9d873d3..08977b6b221 100755 --- a/cluster/ubuntu/reconfDocker.sh +++ b/cluster/ubuntu/reconfDocker.sh @@ -16,14 +16,13 @@ # reconfigure docker network setting -source ~/kube/config-default.sh +source "$HOME/kube/${KUBE_CONFIG_FILE##*/}" -if [ "$(id -u)" != "0" ]; then +if [[ "$(id -u)" != "0" ]]; then echo >&2 "Please run as root" exit 1 fi - function config_etcd { attempt=0 while true; do @@ -72,4 +71,7 @@ elif [[ $1 == "ai" ]]; then restart_docker elif [[ $1 == "a" ]]; then config_etcd -fi +else + echo "Another arguement is required." + exit 1 +fi diff --git a/cluster/ubuntu/util.sh b/cluster/ubuntu/util.sh index cd82c86f41a..6d81ee0a3b0 100755 --- a/cluster/ubuntu/util.sh +++ b/cluster/ubuntu/util.sh @@ -268,7 +268,7 @@ EOF # Vars set: # KUBE_MASTER_IP function detect-master() { - source "${KUBE_ROOT}/cluster/ubuntu/${KUBE_CONFIG_FILE:-config-default.sh}" + source "${KUBE_CONFIG_FILE}" setClusterInfo export KUBE_MASTER="${MASTER}" export KUBE_MASTER_IP="${MASTER_IP}" @@ -282,7 +282,7 @@ function detect-master() { # Vars set: # KUBE_NODE_IP_ADDRESS (array) function detect-nodes() { - source "${KUBE_ROOT}/cluster/ubuntu/${KUBE_CONFIG_FILE:-config-default.sh}" + source "${KUBE_CONFIG_FILE}" KUBE_NODE_IP_ADDRESSES=() setClusterInfo @@ -306,7 +306,8 @@ function detect-nodes() { # Instantiate a kubernetes cluster on ubuntu function kube-up() { - source "${KUBE_ROOT}/cluster/ubuntu/${KUBE_CONFIG_FILE:-config-default.sh}" + export KUBE_CONFIG_FILE=${KUBE_CONFIG_FILE:-${KUBE_ROOT}/cluster/ubuntu/config-default.sh} + source "${KUBE_CONFIG_FILE}" # downloading tarball release "${KUBE_ROOT}/cluster/ubuntu/download-release.sh" @@ -357,7 +358,7 @@ function provision-master() { scp -r $SSH_OPTS \ saltbase/salt/generate-cert/make-ca-cert.sh \ ubuntu/reconfDocker.sh \ - ubuntu/${KUBE_CONFIG_FILE:-config-default.sh} \ + "${KUBE_CONFIG_FILE}" \ ubuntu/util.sh \ ubuntu/master/* \ ubuntu/binaries/master/ \ @@ -407,7 +408,7 @@ function provision-master() { mkdir -p /opt/bin/ cp ~/kube/master/* /opt/bin/ service etcd start - FLANNEL_NET=\"${FLANNEL_NET}\" ~/kube/reconfDocker.sh a + FLANNEL_NET=\"${FLANNEL_NET}\" KUBE_CONFIG_FILE=\"${KUBE_CONFIG_FILE}\" ~/kube/reconfDocker.sh a '" || { echo "Deploying master on machine ${MASTER_IP} failed" exit 1 @@ -422,7 +423,7 @@ function provision-node() { # copy the binaries and scripts to the ~/kube directory on the node scp -r $SSH_OPTS \ - ubuntu/${KUBE_CONFIG_FILE:-config-default.sh} \ + "${KUBE_CONFIG_FILE}" \ ubuntu/util.sh \ ubuntu/reconfDocker.sh \ ubuntu/minion/* \ @@ -459,7 +460,7 @@ function provision-node() { mkdir -p /opt/bin/ cp ~/kube/minion/* /opt/bin service flanneld start - ~/kube/reconfDocker.sh i + KUBE_CONFIG_FILE=\"${KUBE_CONFIG_FILE}\" ~/kube/reconfDocker.sh i '" || { echo "Deploying node on machine ${1#*@} failed" exit 1 @@ -476,7 +477,7 @@ function provision-masterandnode() { # scp order matters scp -r $SSH_OPTS \ saltbase/salt/generate-cert/make-ca-cert.sh \ - ubuntu/${KUBE_CONFIG_FILE:-config-default.sh} \ + "${KUBE_CONFIG_FILE}" \ ubuntu/util.sh \ ubuntu/minion/* \ ubuntu/master/* \ @@ -539,7 +540,7 @@ function provision-masterandnode() { cp ~/kube/minion/* /opt/bin/ service etcd start - FLANNEL_NET=\"${FLANNEL_NET}\" ~/kube/reconfDocker.sh ai + FLANNEL_NET=\"${FLANNEL_NET}\" KUBE_CONFIG_FILE=\"${KUBE_CONFIG_FILE}\" ~/kube/reconfDocker.sh ai '" || { echo "Deploying master and node on machine ${MASTER_IP} failed" exit 1 @@ -562,9 +563,11 @@ function check-pods-torn-down() { # Delete a kubernetes cluster function kube-down() { - export KUBECTL_PATH="${KUBE_ROOT}/cluster/ubuntu/binaries/kubectl" - source "${KUBE_ROOT}/cluster/ubuntu/${KUBE_CONFIG_FILE:-config-default.sh}" + + export KUBE_CONFIG_FILE=${KUBE_CONFIG_FILE:-${KUBE_ROOT}/cluster/ubuntu/config-default.sh} + source "${KUBE_CONFIG_FILE}" + source "${KUBE_ROOT}/cluster/common.sh" tear_down_alive_resources @@ -647,7 +650,8 @@ function prepare-push() { # Update a kubernetes master with expected release function push-master() { - source "${KUBE_ROOT}/cluster/ubuntu/${KUBE_CONFIG_FILE:-config-default.sh}" + export KUBE_CONFIG_FILE=${KUBE_CONFIG_FILE:-${KUBE_ROOT}/cluster/ubuntu/config-default.sh} + source "${KUBE_CONFIG_FILE}" if [[ ! -f "${KUBE_ROOT}/cluster/ubuntu/binaries/master/kube-apiserver" ]]; then echo "There is no required release of kubernetes, please check first" @@ -702,7 +706,8 @@ function push-master() { # Update a kubernetes node with expected release function push-node() { - source "${KUBE_ROOT}/cluster/ubuntu/${KUBE_CONFIG_FILE:-config-default.sh}" + export KUBE_CONFIG_FILE=${KUBE_CONFIG_FILE:-${KUBE_ROOT}/cluster/ubuntu/config-default.sh} + source "${KUBE_CONFIG_FILE}" if [[ ! -f "${KUBE_ROOT}/cluster/ubuntu/binaries/minion/kubelet" ]]; then echo "There is no required release of kubernetes, please check first" @@ -764,7 +769,8 @@ function push-node() { # Update a kubernetes cluster with expected source function kube-push() { prepare-push - source "${KUBE_ROOT}/cluster/ubuntu/${KUBE_CONFIG_FILE:-config-default.sh}" + export KUBE_CONFIG_FILE=${KUBE_CONFIG_FILE:-${KUBE_ROOT}/cluster/ubuntu/config-default.sh} + source "${KUBE_CONFIG_FILE}" if [[ ! -f "${KUBE_ROOT}/cluster/ubuntu/binaries/master/kube-apiserver" ]]; then echo "There is no required release of kubernetes, please check first" diff --git a/docs/getting-started-guides/ubuntu.md b/docs/getting-started-guides/ubuntu.md index 5debbc5dcd1..6d34276fa1a 100644 --- a/docs/getting-started-guides/ubuntu.md +++ b/docs/getting-started-guides/ubuntu.md @@ -156,7 +156,7 @@ bring up the whole cluster. `$ KUBERNETES_PROVIDER=ubuntu ./kube-up.sh` -The scripts automatically `scp` binaries and config files to all the machines and start kubernetes +The scripts automatically copy binaries and config files to all the machines via `scp` and start kubernetes service on them. The only thing you need to do is to type the sudo password when promoted. ```console