blob: 5fcf67a2eaf58f94a3cf2fdb48c60c11488fc9e0 [file] [log] [blame]
romeromonsere366b1a2019-11-19 19:49:26 +01001#!/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
20HERE=$(dirname $(readlink -f ${BASH_SOURCE[0]}))
21source $HERE/versions_monitoring
22V_OPERATOR=""
23
24# Assign versions
25V_OPERATOR=$PROMETHEUS_OPERATOR
26
27WORK_DIR=$HERE
28CHARTS_DIR="$HERE/helm_charts"
29
30# This two objects are not exporting metrics
31DELETE_YAML_DAHSBOARDS="etcd.yaml \
32 proxy.yaml"
33DELETE_YAML_RULES="etcd.yaml"
34
35# There is a bug in this dashboard and it is necessary to change it
36CHANGE_YAML_DAHSBOARDS="statefulset.yaml"
37
38# Delete old versions
39cd $CHARTS_DIR
40
41rm -rf prometheus-operator > /dev/null 2>&1
42rm prometheus-operator* > /dev/null 2>&1
43
44echo "Fetching stable/prometheus-operator..."
45helm fetch --version=$V_OPERATOR stable/prometheus-operator
46tar xvf prometheus-operator-$V_OPERATOR.tgz > /dev/null 2>&1
47
48cd $WORK_DIR
49
50# Deleting grafana dashboard
51echo "Changing prometheus-operator grafana dashboards...."
52cd $CHARTS_DIR/prometheus-operator/templates/grafana/dashboards-1.14
53for i in $DELETE_YAML_DAHSBOARDS
54do
55 #echo "Deleting $i...."
56 rm $i
57done
58
59# Change CHANGE_YAML_DAHSBOARDS because it has an error
60mv $CHANGE_YAML_DAHSBOARDS ${CHANGE_YAML_DAHSBOARDS}.ORI
61cat ${CHANGE_YAML_DAHSBOARDS}.ORI | \
62 sed 's@{job=\\\"kube-state-metrics\\\"}, cluster=\\\"\$cluster\\\",@{job=\\\"kube-state-metrics\\\", cluster=\\\"\$cluster\\\"},@' > \
63 $CHANGE_YAML_DAHSBOARDS
64chmod 755 $CHANGE_YAML_DAHSBOARDS
65rm ${CHANGE_YAML_DAHSBOARDS}.ORI
66
67cd $WORK_DIR
68
69# Deleting prometheus rules
70echo "Changing prometheus-operator rules...."
71cd $CHARTS_DIR/prometheus-operator/templates/prometheus/rules-1.14
72for i in $DELETE_YAML_RULES
73do
74 #echo "Deleting $i...."
75 rm $i
76done
77
romeromonser5bed3ad2019-12-10 18:25:55 +010078# Deleting Grafana dependence to avoid it installation
79sed -i -e '/.*- name: grafana.*/,+3d' $CHARTS_DIR/prometheus-operator/requirements.yaml
80sed -i -e '/.*- name: grafana.*/,+2d' $CHARTS_DIR/prometheus-operator/requirements.lock
81rm -rf $CHARTS_DIR/prometheus-operator/charts/grafana
82
romeromonsere366b1a2019-11-19 19:49:26 +010083exit 0