Add 'contrib/kube-prometheus/' from commit '81c0d2f4d30f63a4e274c2870c5afc89241827b0'
git-subtree-dir: contrib/kube-prometheus
git-subtree-mainline: 050ca21276696c8603375c699513ec487301ed62
git-subtree-split: 81c0d2f4d3
This commit is contained in:
41
hack/cluster-monitoring/deploy
Executable file
41
hack/cluster-monitoring/deploy
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [ -z "${KUBECONFIG}" ]; then
|
||||
export KUBECONFIG=~/.kube/config
|
||||
fi
|
||||
|
||||
if [ -z "${NAMESPACE}" ]; then
|
||||
NAMESPACE=monitoring
|
||||
fi
|
||||
|
||||
kubectl create namespace "$NAMESPACE"
|
||||
|
||||
kctl() {
|
||||
kubectl --namespace "$NAMESPACE" "$@"
|
||||
}
|
||||
|
||||
kctl apply -f manifests/prometheus-operator.yaml
|
||||
|
||||
# Wait for TPRs to be ready.
|
||||
printf "Waiting for Operator to register third party objects..."
|
||||
until kctl get servicemonitor > /dev/null 2>&1; do sleep 1; printf "."; done
|
||||
until kctl get prometheus > /dev/null 2>&1; do sleep 1; printf "."; done
|
||||
until kctl get alertmanager > /dev/null 2>&1; do sleep 1; printf "."; done
|
||||
echo "done!"
|
||||
|
||||
kctl apply -f manifests/exporters
|
||||
kctl apply -f manifests/grafana
|
||||
|
||||
kctl apply -f manifests/prometheus/prometheus-k8s-rules.yaml
|
||||
kctl apply -f manifests/prometheus/prometheus-k8s-service.yaml
|
||||
|
||||
kctl apply -f manifests/alertmanager/alertmanager-config.yaml
|
||||
kctl apply -f manifests/alertmanager/alertmanager-service.yaml
|
||||
|
||||
# `kubectl apply` is currently not working for third party resources so we are
|
||||
# using `kubectl create` here for the time being.
|
||||
# (https://github.com/kubernetes/kubernetes/issues/29542)
|
||||
kctl create -f manifests/prometheus/prometheus-k8s-servicemonitors.yaml
|
||||
kctl create -f manifests/prometheus/prometheus-k8s.yaml
|
||||
kctl create -f manifests/alertmanager/alertmanager.yaml
|
||||
|
6
hack/cluster-monitoring/minikube-deploy
Executable file
6
hack/cluster-monitoring/minikube-deploy
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
hack/cluster-monitoring/deploy
|
||||
|
||||
awk 'FNR==1{print "---"}1' manifests/k8s/minikube/*.yaml | sed s/MINIKUBE_IP/`minikube ip`/g | kubectl --namespace=kube-system apply -f -
|
||||
|
6
hack/cluster-monitoring/minikube-teardown
Executable file
6
hack/cluster-monitoring/minikube-teardown
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
hack/cluster-monitoring/teardown
|
||||
|
||||
kubectl --namespace=kube-system delete -f manifests/k8s/minikube
|
||||
|
6
hack/cluster-monitoring/self-hosted-deploy
Executable file
6
hack/cluster-monitoring/self-hosted-deploy
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
hack/cluster-monitoring/deploy
|
||||
|
||||
kubectl --namespace=kube-system apply -f manifests/k8s/self-hosted
|
||||
|
6
hack/cluster-monitoring/self-hosted-teardown
Executable file
6
hack/cluster-monitoring/self-hosted-teardown
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
hack/cluster-monitoring/teardown
|
||||
|
||||
kubectl --namespace=kube-system delete -f manifests/k8s/self-hosted
|
||||
|
24
hack/cluster-monitoring/teardown
Executable file
24
hack/cluster-monitoring/teardown
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [ -z "${KUBECONFIG}" ]; then
|
||||
export KUBECONFIG=~/.kube/config
|
||||
fi
|
||||
|
||||
if [ -z "${NAMESPACE}" ]; then
|
||||
NAMESPACE=monitoring
|
||||
fi
|
||||
|
||||
kctl() {
|
||||
kubectl --namespace "$NAMESPACE" "$@"
|
||||
}
|
||||
|
||||
kctl delete -f manifests/exporters
|
||||
kctl delete -f manifests/grafana
|
||||
kctl delete -f manifests/prometheus
|
||||
kctl delete -f manifests/alertmanager
|
||||
|
||||
# Hack: wait a bit to let the controller delete the deployed Prometheus server.
|
||||
sleep 5
|
||||
|
||||
kctl delete -f manifests/prometheus-operator.yaml
|
||||
|
19
hack/example-service-monitoring/deploy
Executable file
19
hack/example-service-monitoring/deploy
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [ -z "${KUBECONFIG}" ]; then
|
||||
KUBECONFIG=~/.kube/config
|
||||
fi
|
||||
|
||||
if [ -z "${NAMESPACE}" ]; then
|
||||
NAMESPACE=default
|
||||
fi
|
||||
|
||||
kubectl --namespace "$NAMESPACE" --kubeconfig="$KUBECONFIG" apply -f manifests/examples/example-app/prometheus-frontend-svc.yaml
|
||||
kubectl --namespace "$NAMESPACE" --kubeconfig="$KUBECONFIG" apply -f manifests/examples/example-app/example-app.yaml
|
||||
|
||||
# `kubectl apply` is currently not working for third party resources so we are
|
||||
# using `kubectl create` here for the time being.
|
||||
# (https://github.com/kubernetes/kubernetes/issues/29542)
|
||||
kubectl --namespace "$NAMESPACE" --kubeconfig="$KUBECONFIG" create -f manifests/examples/example-app/prometheus-frontend.yaml
|
||||
kubectl --namespace "$NAMESPACE" --kubeconfig="$KUBECONFIG" create -f manifests/examples/example-app/servicemonitor-frontend.yaml
|
||||
|
12
hack/example-service-monitoring/teardown
Executable file
12
hack/example-service-monitoring/teardown
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [ -z "${KUBECONFIG}" ]; then
|
||||
KUBECONFIG=~/.kube/config
|
||||
fi
|
||||
|
||||
if [ -z "${NAMESPACE}" ]; then
|
||||
NAMESPACE=default
|
||||
fi
|
||||
|
||||
kubectl --namespace "$NAMESPACE" --kubeconfig="$KUBECONFIG" delete -f manifests/examples/example-app
|
||||
|
8
hack/scripts/generate-configmaps.sh
Executable file
8
hack/scripts/generate-configmaps.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Generate Alert Rules ConfigMap
|
||||
kubectl create configmap --dry-run=true prometheus-k8s-rules --from-file=assets/prometheus/rules/ -oyaml > manifests/prometheus/prometheus-k8s-rules.yaml
|
||||
|
||||
# Generate Dashboard ConfigMap
|
||||
kubectl create configmap --dry-run=true grafana-dashboards --from-file=assets/grafana/ -oyaml > manifests/grafana/grafana-dashboards.yaml
|
||||
|
50
hack/scripts/wrap-dashboard.sh
Executable file
50
hack/scripts/wrap-dashboard.sh
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash -eu
|
||||
|
||||
# Intended usage:
|
||||
# * Edit dashboard in Grafana (you need to login first with admin/admin
|
||||
# login/password).
|
||||
# * Save dashboard in Grafana to check is specification is correct.
|
||||
# Looks like this is the only way to check is dashboard specification
|
||||
# has error.
|
||||
# * Download dashboard specification as JSON file in Grafana:
|
||||
# Share -> Export -> Save to file.
|
||||
# * Wrap dashboard specification to make it digestable by kube-prometheus:
|
||||
# ./hack/scripts/wrap-dashboard.sh Nodes-1488465802729.json
|
||||
# * Replace dashboard specification:
|
||||
# mv Nodes-1488465802729.json assets/grafana/node-dashboard.json
|
||||
# * Regenerate Grafana configmap:
|
||||
# ./hack/scripts/generate-configmaps.sh
|
||||
# * Apply new configmap:
|
||||
# kubectl -n monitoring apply -f manifests/grafana/grafana-cm.yaml
|
||||
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Usage: $0 path-to-dashboard.json"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
json=$1
|
||||
temp=$(tempfile -m 0644)
|
||||
|
||||
cat >> $temp <<EOF
|
||||
{
|
||||
"dashboard":
|
||||
EOF
|
||||
|
||||
cat $json >> $temp
|
||||
|
||||
cat >> $temp <<EOF
|
||||
,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "DS_PROMETHEUS",
|
||||
"pluginId": "prometheus",
|
||||
"type": "datasource",
|
||||
"value": "prometheus"
|
||||
}
|
||||
],
|
||||
"overwrite": true
|
||||
}
|
||||
EOF
|
||||
|
||||
mv $temp $json
|
||||
|
Reference in New Issue
Block a user