Merge pull request #2357 from filbranden/monitoring

Fix bugs and improve monitoring support
pull/6/head
Dawn Chen 2014-11-13 13:59:58 -08:00
commit 8c358f0cae
6 changed files with 36 additions and 15 deletions

View File

@ -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
}

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -475,3 +475,7 @@ function test-teardown {
function setup-monitoring {
echo "TODO"
}
function teardown-monitoring {
echo "TODO"
}

View File

@ -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",