| romeromonser | e366b1a | 2019-11-19 19:49:26 +0100 | [diff] [blame] | 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 | |
| limon | 89a4f0a | 2022-01-26 10:49:39 +0100 | [diff] [blame] | 19 | # Script to generate new charts for kube-prometheus-stack |
| romeromonser | e366b1a | 2019-11-19 19:49:26 +0100 | [diff] [blame] | 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" |
| limon | 89a4f0a | 2022-01-26 10:49:39 +0100 | [diff] [blame] | 29 | mkdir -p $CHARTS_DIR |
| romeromonser | e366b1a | 2019-11-19 19:49:26 +0100 | [diff] [blame] | 30 | |
| romeromonser | e366b1a | 2019-11-19 19:49:26 +0100 | [diff] [blame] | 31 | |
| 32 | # Delete old versions |
| 33 | cd $CHARTS_DIR |
| 34 | |
| limon | 89a4f0a | 2022-01-26 10:49:39 +0100 | [diff] [blame] | 35 | rm -rf kube-prometheus-stack > /dev/null 2>&1 |
| 36 | rm kube-prometheus-stack* > /dev/null 2>&1 |
| romeromonser | e366b1a | 2019-11-19 19:49:26 +0100 | [diff] [blame] | 37 | |
| limon | 89a4f0a | 2022-01-26 10:49:39 +0100 | [diff] [blame] | 38 | echo "Fetching prometheus-community/kube-prometheus-stack..." |
| 39 | helm fetch --version=$V_OPERATOR prometheus-community/kube-prometheus-stack |
| 40 | tar xvf kube-prometheus-stack-$V_OPERATOR.tgz > /dev/null 2>&1 |
| romeromonser | e366b1a | 2019-11-19 19:49:26 +0100 | [diff] [blame] | 41 | cd $WORK_DIR |
| 42 | |
| limon | 89a4f0a | 2022-01-26 10:49:39 +0100 | [diff] [blame] | 43 | |
| 44 | # Patching Grafana dashboards |
| 45 | cd $CHARTS_DIR/kube-prometheus-stack/templates/grafana/dashboards-1.14 |
| limon | 89a4f0a | 2022-01-26 10:49:39 +0100 | [diff] [blame] | 46 | for f in $(find . -name '*.yaml*'); |
| romeromonser | e366b1a | 2019-11-19 19:49:26 +0100 | [diff] [blame] | 47 | do |
| limon | 89a4f0a | 2022-01-26 10:49:39 +0100 | [diff] [blame] | 48 | # 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 |
| romeromonser | e366b1a | 2019-11-19 19:49:26 +0100 | [diff] [blame] | 51 | done |
| romeromonser | e366b1a | 2019-11-19 19:49:26 +0100 | [diff] [blame] | 52 | cd $WORK_DIR |
| 53 | |
| romeromonser | 5bed3ad | 2019-12-10 18:25:55 +0100 | [diff] [blame] | 54 | |
| romeromonser | e366b1a | 2019-11-19 19:49:26 +0100 | [diff] [blame] | 55 | exit 0 |