Fix up formatting and sed usage for heapster deploy.

Also, 'sed -i' isn't supported well across BSD and GNU versions of sed.  See http://stackoverflow.com/questions/5694228/sed-in-place-flag-that-works-both-on-mac-bsd-and-linux.  And we were editing files that were checked in to git with a password.  Instead, do this with class sed redirection in a temp dir.

Fixes #2400.
This commit is contained in:
Joe Beda 2014-11-16 17:01:51 -08:00
parent ccc8bc8289
commit c82bd2127f

View File

@ -590,31 +590,35 @@ function restart-kube-proxy {
# Setup monitoring using heapster and InfluxDB # Setup monitoring using heapster and InfluxDB
function setup-monitoring { function setup-monitoring {
if [[ "${MONITORING}" == "true" ]]; then if [[ "${MONITORING}" == "true" ]]; then
echo "Setting up Cluster Monitoring using Heapster." echo "Setting up cluster monitoring using Heapster."
detect-project
if ! gcutil getfirewall monitoring-heapster &> /dev/null; then if ! gcutil getfirewall monitoring-heapster &> /dev/null; then
gcutil addfirewall monitoring-heapster \ if ! gcutil addfirewall monitoring-heapster \
--project "${PROJECT}" \ --project "${PROJECT}" \
--norespect_terminal_width \ --norespect_terminal_width \
--sleep_between_polls "${POLL_SLEEP_INTERVAL}" \ --sleep_between_polls "${POLL_SLEEP_INTERVAL}" \
--target_tags="${MINION_TAG}" \ --target_tags="${MINION_TAG}" \
--allowed "tcp:80,tcp:8083,tcp:8086,tcp:9200" &> /dev/null; --allowed "tcp:80,tcp:8083,tcp:8086,tcp:9200" &> /dev/null; then
if [ $? -ne 0 ]; then echo "Failed to set up firewall for monitoring" && false
echo "Failed to Setup Firewall for Monitoring" && false
fi fi
fi fi
# Re-use master auth for Grafana # Re-use master auth for Grafana
get-password get-password
sed -i "s/HTTP_USER, \"value\": \"[^\"]*\"/HTTP_USER, \"value\": \"$KUBE_USER\"/g" "${KUBE_ROOT}/examples/monitoring/influx-grafana-pod.json" ensure-temp-dir
sed -i "s/HTTP_PASS, \"value\": \"[^\"]*\"/HTTP_PASS, \"value\": \"$KUBE_PASSWORD\"/g" "${KUBE_ROOT}/examples/monitoring/influx-grafana-pod.json"
local kubectl=${KUBE_ROOT}/cluster/kubectl.sh cp "${KUBE_ROOT}/examples/monitoring/influx-grafana-pod.json" "${KUBE_TEMP}/influx-grafana-pod.0.json"
if "${kubectl}" create -f "${KUBE_ROOT}/examples/monitoring/influx-grafana-pod.json" &> /dev/null \ sed "s/HTTP_USER, \"value\": \"[^\"]*\"/HTTP_USER, \"value\": \"$KUBE_USER\"/g" \
"${KUBE_TEMP}/influx-grafana-pod.0.json" > "${KUBE_TEMP}/influx-grafana-pod.1.json"
sed "s/HTTP_PASS, \"value\": \"[^\"]*\"/HTTP_PASS, \"value\": \"$KUBE_PASSWORD\"/g" \
"${KUBE_TEMP}/influx-grafana-pod.1.json" > "${KUBE_TEMP}/influx-grafana-pod.2.json"
local kubectl="${KUBE_ROOT}/cluster/kubectl.sh"
if "${kubectl}" create -f "${KUBE_TEMP}/influx-grafana-pod.2.json" &> /dev/null \
&& "${kubectl}" create -f "${KUBE_ROOT}/examples/monitoring/influx-grafana-service.json" &> /dev/null \ && "${kubectl}" create -f "${KUBE_ROOT}/examples/monitoring/influx-grafana-service.json" &> /dev/null \
&& "${kubectl}" create -f "${KUBE_ROOT}/examples/monitoring/heapster-pod.json" &> /dev/null; then && "${kubectl}" create -f "${KUBE_ROOT}/examples/monitoring/heapster-pod.json" &> /dev/null; then
dashboardIP="http://`${kubectl} get -o json pod influx-grafana | grep hostIP | awk '{print $2}' | sed 's/[,|\"]//g'`" local dashboard_url="http://$(${kubectl} get -o json pod influx-grafana | grep hostIP | awk '{print $2}' | sed 's/[,|\"]//g')"
echo echo
echo "Grafana dashboard will be available at $dashboardIP. Wait for the monitoring dashboard to be online." echo "Grafana dashboard will be available at $dashboard_url. Wait for the monitoring dashboard to be online."
echo "Use the master user name and password for the dashboard." echo "Use the master user name and password for the dashboard."
echo echo
else else
@ -626,11 +630,10 @@ function setup-monitoring {
function teardown-monitoring { function teardown-monitoring {
if [[ "${MONITORING}" == "true" ]]; then if [[ "${MONITORING}" == "true" ]]; then
detect-project local kubectl="${KUBE_ROOT}/cluster/kubectl.sh"
local kubectl=${KUBE_ROOT}/cluster/kubectl.sh "${kubectl}" delete pods heapster &> /dev/null || true
${kubectl} delete pods heapster &> /dev/null || true "${kubectl}" delete pods influx-grafana &> /dev/null || true
${kubectl} delete pods influx-grafana &> /dev/null || true "${kubectl}" delete services influx-master &> /dev/null || true
${kubectl} delete services influx-master &> /dev/null || true
if gcutil getfirewall monitoring-heapster &> /dev/null; then if gcutil getfirewall monitoring-heapster &> /dev/null; then
gcutil deletefirewall \ gcutil deletefirewall \
--project "${PROJECT}" \ --project "${PROJECT}" \