3 # Copyright 2019 Minsait - Indra S.A.
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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)
19 # Script to generate new charts for prometheus-operator
20 HERE
=$
(dirname $
(readlink
-f ${BASH_SOURCE[0]}))
21 source $HERE/versions_monitoring
25 V_OPERATOR
=$PROMETHEUS_OPERATOR
28 CHARTS_DIR
="$HERE/helm_charts"
30 # This two objects are not exporting metrics
31 DELETE_YAML_DAHSBOARDS
="etcd.yaml \
33 DELETE_YAML_RULES
="etcd.yaml"
35 # There is a bug in this dashboard and it is necessary to change it
36 CHANGE_YAML_DAHSBOARDS
="statefulset.yaml"
41 rm -rf prometheus-operator
> /dev
/null
2>&1
42 rm prometheus-operator
* > /dev
/null
2>&1
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
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
55 #echo "Deleting $i...."
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
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
74 #echo "Deleting $i...."
78 # Deleting Grafana dependence to avoid it installation
79 sed -i -e '/.*- name: grafana.*/,+3d' $CHARTS_DIR/prometheus-operator
/requirements.yaml
80 sed -i -e '/.*- name: grafana.*/,+2d' $CHARTS_DIR/prometheus-operator
/requirements.lock
81 rm -rf $CHARTS_DIR/prometheus-operator
/charts
/grafana