forked from Rub21/k8s-monitoring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·61 lines (52 loc) · 2.18 KB
/
deploy.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
set -e
export GRAFANA_ADMINPASSWORD="${GRAFANA_ADMINPASSWORD:-1234}"
export CLUSTER_NAME=$(kubectl config current-context)
export ENVIROMENT="${ENVIROMENT:-staging}"
kubectl get namespace monitoring || kubectl create namespace monitoring
install_prometheus() {
read -p "Are you sure you want to upgrade/install prometheus in CLUSTER \"${CLUSTER_NAME}\"? (y/n): " confirm
if [[ $confirm == [Yy] ]]; then
# Install/upgrade Prometheus
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm upgrade --install prometheus prometheus-community/prometheus \
--namespace monitoring \
--set server.persistentVolume.enabled=true \
--set server.persistentVolume.size=10Gi \
--set server.persistentVolume.storageClass="gp2"
kubectl get pods -n monitoring
# Install/upgrade Grafana
helm repo add grafana https://grafana.github.io/helm-charts
helm repo update
helm upgrade --install grafana grafana/grafana \
--namespace monitoring \
--set persistence.enabled=true \
--set persistence.size=10Gi \
--set persistence.storageClass="standard" \
--set-string adminPassword="$GRAFANA_ADMINPASSWORD" \
--set forceSecretRewrite=true \
--set nodeSelector."nodegroup_type"="web_large"
kubectl get pods -n monitoring | grep grafana
# Create ingress
kubectl apply -f ingress/${ENVIROMENT}-ingress.yml --namespace monitoring
fi
}
delete_prometheus() {
read -p "Are you sure you want to delete prometheus and grafana from CLUSTER \"${CLUSTER_NAME}\"? (y/n): " confirm
if [[ $confirm == [Yy] ]]; then
helm delete prometheus --namespace monitoring
helm delete grafana --namespace monitoring
kubectl apply -f ingress/${ENVIROMENT}-prometheus-ingress.yml --namespace monitoring
kubectl apply -f ingress/${ENVIROMENT}-grafana-ingress.yml
fi
}
### Main
ACTION=${1:-default}
if [ "$ACTION" == "create" ]; then
install_prometheus
elif [ "$ACTION" == "delete" ]; then
delete_prometheus
else
echo "The action is unknown."
fi