-
Notifications
You must be signed in to change notification settings - Fork 1
/
prometheus.sh
executable file
·47 lines (40 loc) · 1.51 KB
/
prometheus.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
get_operator() {
if [ ! -d ./kube-prometheus-main ]
then
wget https://github.com/prometheus-operator/kube-prometheus/archive/main.zip
unzip main.zip
rm main.zip
else
echo "kube-prometheus-main already downloaded"
fi
}
up() {
get_operator
cd kube-prometheus-main
kubectl create -f manifests/setup
until kubectl get servicemonitors --all-namespaces ; do date; sleep 1; echo "waiting"; done
kubectl create -f manifests/
cd ..
kubectl patch service prometheus-operated -n monitoring --patch-file prometheus-operated-patch.yaml
kubectl patch service prometheus-k8s -n monitoring --patch-file prometheus-operated-patch.yaml
kubectl label namespace monitoring istio-injection=enabled
kubectl rollout restart deployment prometheus-operator -n monitoring
kubectl rollout restart deployment grafana -n monitoring
kubectl rollout restart deployment blackbox-exporter -n monitoring
kubectl rollout restart deployment kube-state-metrics -n monitoring
kubectl rollout restart deployment prometheus-adapter -n monitoring
kubectl create -f prometheus.yaml
ip=`hostname -I | awk '{print $1}'`
echo "Prometheus expose: kubectl port-forward --address=$ip svc/prometheus-operated 9090:9090 -n monitoring"
echo "Grafana expose: kubectl port-forward --address=$ip svc/grafana 3000 -n monitoring"
echo " Grafana user/pass is admin/admin"
}
down() {
get_operator
cd kube-prometheus-main
kubectl delete --ignore-not-found=true -f manifests/ -f manifests/setup
cd ..
kubectl delete -f prometheus.yaml
}
. ./base.sh $1