Skip to content

Commit

Permalink
Fix monitoring setup script.
Browse files Browse the repository at this point in the history
Remove the firewall rule created for monitoring as part of kube-down.
Reuse master auth for Grafana.
  • Loading branch information
vishh authored and filbranden committed Nov 13, 2014
1 parent d677755 commit 46a22b3
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 15 deletions.
34 changes: 21 additions & 13 deletions cluster/gce/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -589,45 +589,53 @@ function restart-kube-proxy {

# Setup monitoring using heapster and InfluxDB
function setup-monitoring {
if [ $MONITORING ]; then
teardown-monitoring
if [[ "${MONITORING}" == "true" ]]; then
echo "Setting up Cluster Monitoring using Heapster."
detect-project
if ! gcutil getfirewall monitoring-heapster &> /dev/null; then
gcutil addfirewall monitoring-heapster \
--project "${PROJECT}" \
--norespect_terminal_width \
--sleep_between_polls "${POLL_SLEEP_INTERVAL}" \
--target_tags="${MINION_TAG}" \
--allowed "tcp:80,tcp:8083,tcp:8086,tcp:9200";
--allowed "tcp:80,tcp:8083,tcp:8086,tcp:9200" &> /dev/null;
if [ $? -ne 0 ]; then
echo "Failed to Setup Firewall for Monitoring" && false
fi
fi

# Re-use master auth for Grafana
get-password
sed -i "s/HTTP_USER, \"value\": \"[^\"]*\"/HTTP_USER, \"value\": \"$KUBE_USER\"/g" "${KUBE_ROOT}/examples/monitoring/influx-grafana-pod.json"
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
${kubectl} create -f "${KUBE_ROOT}/examples/monitoring/influx-grafana-pod.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
if [ $? -ne 0 ]; then
if "${kubectl}" create -f "${KUBE_ROOT}/examples/monitoring/influx-grafana-pod.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
dashboardIP="http://$KUBE_USER:$KUBE_PASSWORD@`${kubectl} get -o json pod influx-grafana | grep hostIP | awk '{print $2}' | sed 's/[,|\"]//g'`"
echo "Grafana dashboard will be available at $dashboardIP. Wait for the monitoring dashboard to be online. Use the master user name and password for the dashboard."
else
echo "Failed to Setup Monitoring"
teardown-monitoring
else
dashboardIP="http://admin:admin@`${kubectl} get -o json pod influx-grafana | grep hostIP | awk '{print $2}' | sed 's/[,|\"]//g'`"
echo "Grafana dashboard will be available at $dashboardIP. Wait for the monitoring dashboard to be online."
fi
fi
}

function teardown-monitoring {
if [ $MONITORING ]; then
if [[ "${MONITORING}" == "true" ]]; then
detect-project
local kubectl=${KUBE_ROOT}/cluster/kubectl.sh
${kubectl} delete pods heapster &> /dev/null || true
${kubectl} delete pods influx-grafana &> /dev/null || true
${kubectl} delete services influx-master &> /dev/null || true
gcutil deletefirewall \
if gcutil getfirewall monitoring-heapster &> /dev/null; then
gcutil deletefirewall \
--project "${PROJECT}" \
--norespect_terminal_width \
--sleep_between_polls "${POLL_SLEEP_INTERVAL}" \
--force \
monitoring-heapster || true > /dev/null
monitoring-heapster &> /dev/null || true
fi
fi
}

Expand Down
1 change: 1 addition & 0 deletions cluster/kube-down.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ source "${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}/util.sh"
echo "Bringing down cluster using provider: $KUBERNETES_PROVIDER"

verify-prereqs
teardown-monitoring
kube-down

echo "Done"
4 changes: 4 additions & 0 deletions cluster/rackspace/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,10 @@ function setup-monitoring {
echo "TODO"
}

function teardown-monitoring {
echo "TODO"
}

# Perform preparations required to run e2e tests
function prepare-e2e() {
echo "Rackspace doesn't need special preparations for e2e tests"
Expand Down
4 changes: 4 additions & 0 deletions cluster/vagrant/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ function setup-monitoring {
echo "TODO"
}

function teardown-monitoring {
echo "TODO"
}

# Perform preparations required to run e2e tests
function prepare-e2e() {
echo "Vagrant doesn't need special preparations for e2e tests"
Expand Down
4 changes: 4 additions & 0 deletions cluster/vsphere/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -475,3 +475,7 @@ function test-teardown {
function setup-monitoring {
echo "TODO"
}

function teardown-monitoring {
echo "TODO"
}
4 changes: 2 additions & 2 deletions examples/monitoring/influx-grafana-pod.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"name": "grafana",
"image": "kubernetes/heapster_grafana",
"ports": [{"containerPort": 80, "hostPort": 80}],
"env": [{"name": HTTP_USER, "value": admin},
{"name": HTTP_PASS, "value": admin}],
"env": [{"name": HTTP_USER, "value": "admin"},
{"name": HTTP_PASS, "value": "admin"}],
}, {
"name": "elasticsearch",
"image": "dockerfile/elasticsearch",
Expand Down

0 comments on commit 46a22b3

Please sign in to comment.