Use Heapster as an in-built monitoring solution for Kubernetes in GCE.

Users will have an option to enable it when they setup their cluster (kube-up).
This commit is contained in:
Vishnu Kannan
2014-11-06 19:35:33 +00:00
parent 5590adb2aa
commit edf6d8ee3f
6 changed files with 144 additions and 0 deletions

View File

@@ -429,6 +429,9 @@ EOF
function kube-down {
# Detect the project into $PROJECT
detect-project
# Monitoring might have been setup. It doesn't hurt to attempt shutdown even it wasn't setup.
teardown-monitoring
echo "Bringing down cluster"
gcutil deletefirewall \
@@ -569,3 +572,29 @@ function ssh-to-node {
function restart-kube-proxy {
ssh-to-node "$1" "sudo /etc/init.d/kube-proxy restart"
}
# Setup monitoring using heapster and InfluxDB
function setup-monitoring {
read -p "Setup monitoring of the cluster using heapster (https://github.com/GoogleCloudPlatform/heapster) [Y|N]? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
teardown-monitoring
kubectl.sh create -f "${KUBE_ROOT}/examples/monitoring/influx-grafana-pod.json" &&
kubectl.sh create -f "${KUBE_ROOT}/examples/monitoring/influx-grafana-service.json" &&
kubectl.sh create -f "${KUBE_ROOT}/examples/monitoring/heapster-pod.json"
if [ $? -ne 0 ]; then
teardown-monitoring
else
dashboardIP="http://`kubectl.sh get -o json pod influx-grafana | grep hostIP | awk '{print $2}' | sed 's/[,|\"]//g'`"
echo "Grafana dashboard is available at $dashboardIP"
echo "username is 'admin' and password is 'admin'"
fi
fi
}
function teardown-monitoring {
kubectl.sh delete pods heapster || true
kubectl.sh delete pods influx-grafana || true
kubectl.sh delete services influx-master || true
}