blob: 7f93b9895a158ae24ee16739e8a0e00602b4aad3 [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
limon89a4f0a2022-01-26 10:49:39 +010019# Script to generate new charts for kube-prometheus-stack
romeromonsere366b1a2019-11-19 19:49:26 +010020HERE=$(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"
limon89a4f0a2022-01-26 10:49:39 +010029mkdir -p $CHARTS_DIR
romeromonsere366b1a2019-11-19 19:49:26 +010030
romeromonsere366b1a2019-11-19 19:49:26 +010031
32# Delete old versions
33cd $CHARTS_DIR
34
limon89a4f0a2022-01-26 10:49:39 +010035rm -rf kube-prometheus-stack > /dev/null 2>&1
36rm kube-prometheus-stack* > /dev/null 2>&1
romeromonsere366b1a2019-11-19 19:49:26 +010037
limon89a4f0a2022-01-26 10:49:39 +010038echo "Fetching prometheus-community/kube-prometheus-stack..."
39helm fetch --version=$V_OPERATOR prometheus-community/kube-prometheus-stack
40tar xvf kube-prometheus-stack-$V_OPERATOR.tgz > /dev/null 2>&1
romeromonsere366b1a2019-11-19 19:49:26 +010041cd $WORK_DIR
42
limon89a4f0a2022-01-26 10:49:39 +010043
44# Patching Grafana dashboards
45cd $CHARTS_DIR/kube-prometheus-stack/templates/grafana/dashboards-1.14
limon89a4f0a2022-01-26 10:49:39 +010046for f in $(find . -name '*.yaml*');
romeromonsere366b1a2019-11-19 19:49:26 +010047do
limon89a4f0a2022-01-26 10:49:39 +010048 # Set the correct datasource in all dashboards
49 linenumber=`cat -n $f | grep -A8 '"name": "datasource"' | grep regex | awk '{print $1}'`
50 sed -e "$linenumber s/\"regex\": \"\"/\"regex\": \"Prometheus\"/" -i $f
romeromonsere366b1a2019-11-19 19:49:26 +010051done
romeromonsere366b1a2019-11-19 19:49:26 +010052cd $WORK_DIR
53
romeromonser5bed3ad2019-12-10 18:25:55 +010054
romeromonsere366b1a2019-11-19 19:49:26 +010055exit 0