Merge pull request #2208 from vishh/monitoring

Use Heapster as an in-built monitoring solution for Kubernetes in GCE.
This commit is contained in:
Daniel Smith 2014-11-07 12:31:36 -08:00
commit ec246adbf7
11 changed files with 124 additions and 0 deletions

View File

@ -35,3 +35,5 @@ MINION_SCOPES="compute-rw"
# Increase the sleep interval value if concerned about API rate limits. 3, in seconds, is the default.
POLL_SLEEP_INTERVAL=3
PORTAL_NET="10.0.0.0/16"
# When set to true, heapster will be setup as part of the cluster bring up.
MONITORING=true

View File

@ -35,3 +35,4 @@ MINION_SCOPES=""
# Increase the sleep interval value if concerned about API rate limits. 3, in seconds, is the default.
POLL_SLEEP_INTERVAL=3
PORTAL_NET="10.0.0.0/16"
MONITORING=false

View File

@ -569,3 +569,46 @@ 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 {
if [ $MONITORING ]; then
teardown-monitoring
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";
if [ $? -ne 0 ]; then
echo "Failed to Setup Firewall for Monitoring" && false
fi
fi
kubectl.sh create -f "${KUBE_ROOT}/examples/monitoring/influx-grafana-pod.json" > /dev/null &&
kubectl.sh create -f "${KUBE_ROOT}/examples/monitoring/influx-grafana-service.json" > /dev/null &&
kubectl.sh create -f "${KUBE_ROOT}/examples/monitoring/heapster-pod.json" > /dev/null
if [ $? -ne 0 ]; then
echo "Failed to Setup Monitoring"
teardown-monitoring
else
dashboardIP="http://admin:admin@`kubectl.sh 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
kubectl.sh delete pods heapster &> /dev/null || true
kubectl.sh delete pods influx-grafana &> /dev/null || true
kubectl.sh delete services influx-master &> /dev/null || true
gcutil deletefirewall \
--project "${PROJECT}" \
--norespect_terminal_width \
--sleep_between_polls "${POLL_SLEEP_INTERVAL}" \
--force \
monitoring-heapster || true > /dev/null
fi
}

View File

@ -34,5 +34,6 @@ verify-prereqs
kube-up
"${KUBE_ROOT}/cluster/validate-cluster.sh"
setup-monitoring
echo "Done"

View File

@ -322,3 +322,7 @@ kube-up() {
echo " subject to \"Man in the middle\" type attacks."
echo
}
function setup-monitoring {
echo "TODO"
}

View File

@ -172,3 +172,7 @@ function ssh-to-node {
function restart-kube-proxy {
ssh-to-node "$1" "sudo systemctl restart kube-proxy"
}
function setup-monitoring {
echo "TODO"
}

View File

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

View File

@ -0,0 +1,3 @@
# Heapster
Heapster enables monitoring of Kubernetes Clusters using [cAdvisor](https://github.com/google/cadvisor). Detailed information about heapster can be found [here](https://github.com/GoogleCloudPlatform/heapster).

View File

@ -0,0 +1,18 @@
{
"id": "heapster",
"kind": "Pod",
"apiVersion": "v1beta1",
"desiredState": {
"manifest": {
"version": "v1beta1",
"id": "heapster",
"containers": [{
"name": "heapster",
"image": "kubernetes/heapster",
}]
}
},
"labels": {
"name": "heapster",
}
}

View File

@ -0,0 +1,34 @@
{
"id": "influx-grafana",
"kind": "Pod",
"apiVersion": "v1beta1",
"desiredState": {
"manifest": {
"version": "v1beta1",
"id": "influx-grafana",
"containers": [{
"name": "influxdb",
"image": "kubernetes/heapster_influxdb",
"ports": [
{"containerPort": 8083, "hostPort": 8083},
{"containerPort": 8086, "hostPort": 8086},
{"containerPort": 8090, "hostPort": 8090},
{"containerPort": 8099, "hostPort": 8099}]
}, {
"name": "grafana",
"image": "kubernetes/heapster_grafana",
"ports": [{"containerPort": 80, "hostPort": 80}],
"env": [{"name": HTTP_USER, "value": admin},
{"name": HTTP_PASS, "value": admin}],
}, {
"name": "elasticsearch",
"image": "dockerfile/elasticsearch",
"ports": [{"containerPort": 9200, "hostPort": 9200},
{"containerPort": 9300}],
}]
},
},
"labels": {
"name": "influxdb",
}
}

View File

@ -0,0 +1,10 @@
{
"id": "influx-master",
"kind": "Service",
"apiVersion": "v1beta1",
"port": 8085,
"containerPort": 8086,
"provider": "kubernetes-default",
"component": "influxdb",
"selector": { "name": "influxdb" }
}