7ac07ddc96ac8503631dabc1ead81d9c2390b15f
[osm/devops.git] / installers / k8s / change-charts-prometheus-operator.sh
1 #!/bin/bash
2
3 # Copyright 2019 Minsait - Indra S.A.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 # Author: Jose Manuel Palacios (jmpalacios@minsait.com)
17 # Author: Jose Antonio Martinez (jamartinezv@minsait.com)
18
19 # Script to generate new charts for prometheus-operator
20 HERE=$(dirname $(readlink -f ${BASH_SOURCE[0]}))
21 source $HERE/versions_monitoring
22 V_OPERATOR=""
23
24 # Assign versions
25 V_OPERATOR=$PROMETHEUS_OPERATOR
26
27 WORK_DIR=$HERE
28 CHARTS_DIR="$HERE/helm_charts"
29
30 # This two objects are not exporting metrics
31 DELETE_YAML_DAHSBOARDS="etcd.yaml \
32 proxy.yaml"
33 DELETE_YAML_RULES="etcd.yaml"
34
35 # There is a bug in this dashboard and it is necessary to change it
36 CHANGE_YAML_DAHSBOARDS="statefulset.yaml"
37
38 # Delete old versions
39 cd $CHARTS_DIR
40
41 rm -rf prometheus-operator > /dev/null 2>&1
42 rm prometheus-operator* > /dev/null 2>&1
43
44 echo "Fetching stable/prometheus-operator..."
45 helm fetch --version=$V_OPERATOR stable/prometheus-operator
46 tar xvf prometheus-operator-$V_OPERATOR.tgz > /dev/null 2>&1
47
48 cd $WORK_DIR
49
50 # Deleting grafana dashboard
51 echo "Changing prometheus-operator grafana dashboards...."
52 cd $CHARTS_DIR/prometheus-operator/templates/grafana/dashboards-1.14
53 for i in $DELETE_YAML_DAHSBOARDS
54 do
55 #echo "Deleting $i...."
56 rm $i
57 done
58
59 # Change CHANGE_YAML_DAHSBOARDS because it has an error
60 mv $CHANGE_YAML_DAHSBOARDS ${CHANGE_YAML_DAHSBOARDS}.ORI
61 cat ${CHANGE_YAML_DAHSBOARDS}.ORI | \
62 sed 's@{job=\\\"kube-state-metrics\\\"}, cluster=\\\"\$cluster\\\",@{job=\\\"kube-state-metrics\\\", cluster=\\\"\$cluster\\\"},@' > \
63 $CHANGE_YAML_DAHSBOARDS
64 chmod 755 $CHANGE_YAML_DAHSBOARDS
65 rm ${CHANGE_YAML_DAHSBOARDS}.ORI
66
67 cd $WORK_DIR
68
69 # Deleting prometheus rules
70 echo "Changing prometheus-operator rules...."
71 cd $CHARTS_DIR/prometheus-operator/templates/prometheus/rules-1.14
72 for i in $DELETE_YAML_RULES
73 do
74 #echo "Deleting $i...."
75 rm $i
76 done
77
78 exit 0