1
0
Fork 0
mirror of https://github.com/prometheus-operator/prometheus-operator.git synced 2025-04-16 09:16:38 +00:00
prometheus-operator/contrib/kube-prometheus/hack/cluster-monitoring/deploy
2018-04-28 19:05:19 +01:00

38 lines
1.9 KiB
Bash
Executable file

#!/usr/bin/env bash
# exit immediately when a command fails
set -e
# only exit with zero if all commands of the pipeline exit successfully
set -o pipefail
# error on unset variables
set -u
# print each command before executing it
set -x
manifest_prefix=${1-./manifests}
kubectl create namespace monitoring
find ${manifest_prefix}/prometheus-operator/ -type f ! -name service-monitor.yaml -exec kubectl apply -f {} \;
# Wait for CRDs to be ready.
printf "Waiting for Operator to register custom resource definitions..."
until kubectl get customresourcedefinitions servicemonitors.monitoring.coreos.com > /dev/null 2>&1; do sleep 1; printf "."; done
until kubectl get customresourcedefinitions prometheuses.monitoring.coreos.com > /dev/null 2>&1; do sleep 1; printf "."; done
until kubectl get customresourcedefinitions alertmanagers.monitoring.coreos.com > /dev/null 2>&1; do sleep 1; printf "."; done
until kubectl get servicemonitors.monitoring.coreos.com > /dev/null 2>&1; do sleep 1; printf "."; done
until kubectl get prometheuses.monitoring.coreos.com > /dev/null 2>&1; do sleep 1; printf "."; done
until kubectl get alertmanagers.monitoring.coreos.com > /dev/null 2>&1; do sleep 1; printf "."; done
echo "done!"
# need to ensure that ServiceMonitors are registered before we can create the prometheus-operator ServiceMonitor
kubectl apply -f ${manifest_prefix}/prometheus-operator/service-monitor.yaml
kubectl apply -f ${manifest_prefix}/node-exporter/
kubectl apply -f ${manifest_prefix}/kube-state-metrics/
find ${manifest_prefix}/grafana/ -type f ! -name dashboard-definitions.yaml -exec kubectl apply -f {} \;
# kubectl apply wants to put the previous version in an annotation, which is too large, therefore create instead of apply
kubectl create -f ${manifest_prefix}/grafana/dashboard-definitions.yaml
kubectl apply -f ${manifest_prefix}/prometheus/
kubectl apply -f ${manifest_prefix}/alertmanager/