start-kubemark.sh: clean up the shell script.
Do some cleanups to start-kubemark.sh. 1. Add double quotes around variables which are expanded. This is done even on those variables which probably won't have spaces, globs or similar (such as $MASTER_IP) to stay consistent. 2. In one place, change old-type `...` subshell invocation to $(...) to stay consistent through the file. 3. Remove useless echo commands in expressions: FOO=$(echo "$bar") becomes FOO="$bar". 4. In a few places, remove double quotes around variables when an expression is already inside them: the variables would have been effectively unquoted. The last change in the patch changes the printing a bit -- the old way did not print whitespace correctly due to inner echo missing the quotes around it. The change should fix the printout: - echo $(echo "${pods}" | grep -v "Running") + echo "${pods}" | grep -v Running
This commit is contained in:
parent
974978a7c7
commit
d4365e056f
@ -21,7 +21,7 @@ set -o nounset
|
|||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
TMP_ROOT="$(dirname "${BASH_SOURCE}")/../.."
|
TMP_ROOT="$(dirname "${BASH_SOURCE}")/../.."
|
||||||
KUBE_ROOT=$(readlink -e ${TMP_ROOT} 2> /dev/null || perl -MCwd -e 'print Cwd::abs_path shift' ${TMP_ROOT})
|
KUBE_ROOT=$(readlink -e "${TMP_ROOT}" 2> /dev/null || perl -MCwd -e 'print Cwd::abs_path shift' "${TMP_ROOT}")
|
||||||
|
|
||||||
source "${KUBE_ROOT}/test/kubemark/skeleton/util.sh"
|
source "${KUBE_ROOT}/test/kubemark/skeleton/util.sh"
|
||||||
source "${KUBE_ROOT}/test/kubemark/cloud-provider-config.sh"
|
source "${KUBE_ROOT}/test/kubemark/cloud-provider-config.sh"
|
||||||
@ -97,7 +97,7 @@ function generate-pki-config {
|
|||||||
kube::util::ensure-temp-dir
|
kube::util::ensure-temp-dir
|
||||||
gen-kube-bearertoken
|
gen-kube-bearertoken
|
||||||
gen-kube-basicauth
|
gen-kube-basicauth
|
||||||
create-certs ${MASTER_IP}
|
create-certs "${MASTER_IP}"
|
||||||
KUBELET_TOKEN=$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64 | tr -d "=+/" | dd bs=32 count=1 2>/dev/null)
|
KUBELET_TOKEN=$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64 | tr -d "=+/" | dd bs=32 count=1 2>/dev/null)
|
||||||
KUBE_PROXY_TOKEN=$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64 | tr -d "=+/" | dd bs=32 count=1 2>/dev/null)
|
KUBE_PROXY_TOKEN=$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64 | tr -d "=+/" | dd bs=32 count=1 2>/dev/null)
|
||||||
NODE_PROBLEM_DETECTOR_TOKEN=$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64 | tr -d "=+/" | dd bs=32 count=1 2>/dev/null)
|
NODE_PROBLEM_DETECTOR_TOKEN=$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64 | tr -d "=+/" | dd bs=32 count=1 2>/dev/null)
|
||||||
@ -213,11 +213,11 @@ function create-and-upload-hollow-node-image {
|
|||||||
fi
|
fi
|
||||||
echo "Copying kubemark binary to ${MAKE_DIR}"
|
echo "Copying kubemark binary to ${MAKE_DIR}"
|
||||||
cp "${KUBEMARK_BIN}" "${MAKE_DIR}"
|
cp "${KUBEMARK_BIN}" "${MAKE_DIR}"
|
||||||
CURR_DIR=`pwd`
|
CURR_DIR=$(pwd)
|
||||||
cd "${MAKE_DIR}"
|
cd "${MAKE_DIR}"
|
||||||
REGISTRY=${KUBEMARK_IMAGE_REGISTRY} IMAGE_TAG=${KUBEMARK_IMAGE_TAG} run-cmd-with-retries "${build_cmd[@]}"
|
REGISTRY=${KUBEMARK_IMAGE_REGISTRY} IMAGE_TAG=${KUBEMARK_IMAGE_TAG} run-cmd-with-retries "${build_cmd[@]}"
|
||||||
rm kubemark
|
rm kubemark
|
||||||
cd $CURR_DIR
|
cd "$CURR_DIR"
|
||||||
fi
|
fi
|
||||||
echo "Created and uploaded the kubemark hollow-node image to docker registry."
|
echo "Created and uploaded the kubemark hollow-node image to docker registry."
|
||||||
}
|
}
|
||||||
@ -227,27 +227,27 @@ function create-and-upload-hollow-node-image {
|
|||||||
# templates, and finally create these resources through kubectl.
|
# templates, and finally create these resources through kubectl.
|
||||||
function create-kube-hollow-node-resources {
|
function create-kube-hollow-node-resources {
|
||||||
# Create kubeconfig for Kubelet.
|
# Create kubeconfig for Kubelet.
|
||||||
KUBELET_KUBECONFIG_CONTENTS=$(echo "apiVersion: v1
|
KUBELET_KUBECONFIG_CONTENTS="apiVersion: v1
|
||||||
kind: Config
|
kind: Config
|
||||||
users:
|
users:
|
||||||
- name: kubelet
|
- name: kubelet
|
||||||
user:
|
user:
|
||||||
client-certificate-data: "${KUBELET_CERT_BASE64}"
|
client-certificate-data: ${KUBELET_CERT_BASE64}
|
||||||
client-key-data: "${KUBELET_KEY_BASE64}"
|
client-key-data: ${KUBELET_KEY_BASE64}
|
||||||
clusters:
|
clusters:
|
||||||
- name: kubemark
|
- name: kubemark
|
||||||
cluster:
|
cluster:
|
||||||
certificate-authority-data: "${CA_CERT_BASE64}"
|
certificate-authority-data: ${CA_CERT_BASE64}
|
||||||
server: https://${MASTER_IP}
|
server: https://${MASTER_IP}
|
||||||
contexts:
|
contexts:
|
||||||
- context:
|
- context:
|
||||||
cluster: kubemark
|
cluster: kubemark
|
||||||
user: kubelet
|
user: kubelet
|
||||||
name: kubemark-context
|
name: kubemark-context
|
||||||
current-context: kubemark-context")
|
current-context: kubemark-context"
|
||||||
|
|
||||||
# Create kubeconfig for Kubeproxy.
|
# Create kubeconfig for Kubeproxy.
|
||||||
KUBEPROXY_KUBECONFIG_CONTENTS=$(echo "apiVersion: v1
|
KUBEPROXY_KUBECONFIG_CONTENTS="apiVersion: v1
|
||||||
kind: Config
|
kind: Config
|
||||||
users:
|
users:
|
||||||
- name: kube-proxy
|
- name: kube-proxy
|
||||||
@ -263,10 +263,10 @@ contexts:
|
|||||||
cluster: kubemark
|
cluster: kubemark
|
||||||
user: kube-proxy
|
user: kube-proxy
|
||||||
name: kubemark-context
|
name: kubemark-context
|
||||||
current-context: kubemark-context")
|
current-context: kubemark-context"
|
||||||
|
|
||||||
# Create kubeconfig for Heapster.
|
# Create kubeconfig for Heapster.
|
||||||
HEAPSTER_KUBECONFIG_CONTENTS=$(echo "apiVersion: v1
|
HEAPSTER_KUBECONFIG_CONTENTS="apiVersion: v1
|
||||||
kind: Config
|
kind: Config
|
||||||
users:
|
users:
|
||||||
- name: heapster
|
- name: heapster
|
||||||
@ -282,10 +282,10 @@ contexts:
|
|||||||
cluster: kubemark
|
cluster: kubemark
|
||||||
user: heapster
|
user: heapster
|
||||||
name: kubemark-context
|
name: kubemark-context
|
||||||
current-context: kubemark-context")
|
current-context: kubemark-context"
|
||||||
|
|
||||||
# Create kubeconfig for Cluster Autoscaler.
|
# Create kubeconfig for Cluster Autoscaler.
|
||||||
CLUSTER_AUTOSCALER_KUBECONFIG_CONTENTS=$(echo "apiVersion: v1
|
CLUSTER_AUTOSCALER_KUBECONFIG_CONTENTS="apiVersion: v1
|
||||||
kind: Config
|
kind: Config
|
||||||
users:
|
users:
|
||||||
- name: cluster-autoscaler
|
- name: cluster-autoscaler
|
||||||
@ -301,10 +301,10 @@ contexts:
|
|||||||
cluster: kubemark
|
cluster: kubemark
|
||||||
user: cluster-autoscaler
|
user: cluster-autoscaler
|
||||||
name: kubemark-context
|
name: kubemark-context
|
||||||
current-context: kubemark-context")
|
current-context: kubemark-context"
|
||||||
|
|
||||||
# Create kubeconfig for NodeProblemDetector.
|
# Create kubeconfig for NodeProblemDetector.
|
||||||
NPD_KUBECONFIG_CONTENTS=$(echo "apiVersion: v1
|
NPD_KUBECONFIG_CONTENTS="apiVersion: v1
|
||||||
kind: Config
|
kind: Config
|
||||||
users:
|
users:
|
||||||
- name: node-problem-detector
|
- name: node-problem-detector
|
||||||
@ -320,10 +320,10 @@ contexts:
|
|||||||
cluster: kubemark
|
cluster: kubemark
|
||||||
user: node-problem-detector
|
user: node-problem-detector
|
||||||
name: kubemark-context
|
name: kubemark-context
|
||||||
current-context: kubemark-context")
|
current-context: kubemark-context"
|
||||||
|
|
||||||
# Create kubeconfig for Kube DNS.
|
# Create kubeconfig for Kube DNS.
|
||||||
KUBE_DNS_KUBECONFIG_CONTENTS=$(echo "apiVersion: v1
|
KUBE_DNS_KUBECONFIG_CONTENTS="apiVersion: v1
|
||||||
kind: Config
|
kind: Config
|
||||||
users:
|
users:
|
||||||
- name: kube-dns
|
- name: kube-dns
|
||||||
@ -339,7 +339,7 @@ contexts:
|
|||||||
cluster: kubemark
|
cluster: kubemark
|
||||||
user: kube-dns
|
user: kube-dns
|
||||||
name: kubemark-context
|
name: kubemark-context
|
||||||
current-context: kubemark-context")
|
current-context: kubemark-context"
|
||||||
|
|
||||||
# Create kubemark namespace.
|
# Create kubemark namespace.
|
||||||
"${KUBECTL}" create -f "${RESOURCE_DIRECTORY}/kubemark-ns.json"
|
"${KUBECTL}" create -f "${RESOURCE_DIRECTORY}/kubemark-ns.json"
|
||||||
@ -445,7 +445,7 @@ function wait-for-hollow-nodes-to-run-or-timeout {
|
|||||||
echo "${running} hollow-nodes are reported as 'Running'"
|
echo "${running} hollow-nodes are reported as 'Running'"
|
||||||
not_running=$(($(echo "${pods}" | grep -v "Running" | wc -l) - 1))
|
not_running=$(($(echo "${pods}" | grep -v "Running" | wc -l) - 1))
|
||||||
echo "${not_running} hollow-nodes are reported as NOT 'Running'"
|
echo "${not_running} hollow-nodes are reported as NOT 'Running'"
|
||||||
echo $(echo "${pods}" | grep -v "Running")
|
echo "${pods}" | grep -v Running
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
nodes=$("${KUBECTL}" --kubeconfig="${LOCAL_KUBECONFIG}" get node 2> /dev/null) || true
|
nodes=$("${KUBECTL}" --kubeconfig="${LOCAL_KUBECONFIG}" get node 2> /dev/null) || true
|
||||||
|
Loading…
Reference in New Issue
Block a user