make e2e/monitor.sh work outside gce

This commit is contained in:
deads2k 2014-12-15 14:58:28 -05:00
parent eb0f32bf0f
commit 8313e5d9bf

View File

@ -26,25 +26,22 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
source "${KUBE_ROOT}/cluster/kube-env.sh" source "${KUBE_ROOT}/cluster/kube-env.sh"
source "${KUBE_ROOT}/cluster/$KUBERNETES_PROVIDER/util.sh" source "${KUBE_ROOT}/cluster/$KUBERNETES_PROVIDER/util.sh"
if [[ "${KUBERNETES_PROVIDER}" != "gce" ]] && [[ "${KUBERNETES_PROVIDER}" != "gke" ]]; then
echo "WARNING: Skipping monitoring.sh for cloud provider: ${KUBERNETES_PROVIDER}."
exit 0
fi
MONITORING="${KUBE_ROOT}/examples/monitoring" MONITORING="${KUBE_ROOT}/examples/monitoring"
KUBECTL="${KUBE_ROOT}/cluster/kubectl.sh" KUBECTL="${KUBE_ROOT}/cluster/kubectl.sh"
MONITORING_FIREWALL_RULE="monitoring-test" MONITORING_FIREWALL_RULE="monitoring-test"
function setup { function setup {
detect-project # This only has work to do on gce and gke
if [[ "${KUBERNETES_PROVIDER}" == "gce" ]] || [[ "${KUBERNETES_PROVIDER}" == "gke" ]]; then
if ! "${GCLOUD}" compute firewall-rules describe $MONITORING_FIREWALL_RULE &> /dev/null; then detect-project
if ! "${GCLOUD}" compute firewall-rules create $MONITORING_FIREWALL_RULE \ if ! "${GCLOUD}" compute firewall-rules describe $MONITORING_FIREWALL_RULE &> /dev/null; then
--project "${PROJECT}" \ if ! "${GCLOUD}" compute firewall-rules create $MONITORING_FIREWALL_RULE \
--network "${NETWORK}" \ --project "${PROJECT}" \
--quiet \ --network "${NETWORK}" \
--allow tcp:80 tcp:8083 tcp:8086 tcp:9200; then --quiet \
echo "Failed to set up firewall for monitoring" && false --allow tcp:80 tcp:8083 tcp:8086 tcp:9200; then
echo "Failed to set up firewall for monitoring" && false
fi
fi fi
fi fi
@ -54,15 +51,19 @@ function setup {
} }
function cleanup { function cleanup {
detect-project
"${KUBECTL}" delete -f "${MONITORING}/influx-grafana-pod.json" || true "${KUBECTL}" delete -f "${MONITORING}/influx-grafana-pod.json" || true
"${KUBECTL}" delete -f "${MONITORING}/influx-grafana-service.json" || true "${KUBECTL}" delete -f "${MONITORING}/influx-grafana-service.json" || true
"${KUBECTL}" delete -f "${MONITORING}/heapster-pod.json" || true "${KUBECTL}" delete -f "${MONITORING}/heapster-pod.json" || true
if "${GCLOUD}" compute firewall-rules describe $MONITORING_FIREWALL_RULE &> /dev/null; then
"${GCLOUD}" compute firewall-rules delete \ # This only has work to do on gce and gke
--project "${PROJECT}" \ if [[ "${KUBERNETES_PROVIDER}" == "gce" ]] || [[ "${KUBERNETES_PROVIDER}" == "gke" ]]; then
--quiet \ detect-project
$MONITORING_FIREWALL_RULE || true if "${GCLOUD}" compute firewall-rules describe $MONITORING_FIREWALL_RULE &> /dev/null; then
"${GCLOUD}" compute firewall-rules delete \
--project "${PROJECT}" \
--quiet \
$MONITORING_FIREWALL_RULE || true
fi
fi fi
} }