#!/usr/bin/env bash crd_version="v0.42.0" namespace=prometheus charts=( etcd-cert-secret.yaml app-servicemonitor.yaml grafana-ldap-toml.yaml grafana-smtp-secret.yaml prometheus-etcd-cert.yaml gitlab-redis-servicemonitor.yaml gitlab-servicemonitor.yaml ingress-nginx-servicemonitor.yaml ) . ../config.sh install_prometheus_crds () { crd=( monitoring.coreos.com_alertmanagers.yaml monitoring.coreos.com_podmonitors.yaml monitoring.coreos.com_probes.yaml monitoring.coreos.com_prometheuses.yaml monitoring.coreos.com_prometheusrules.yaml monitoring.coreos.com_servicemonitors.yaml monitoring.coreos.com_thanosrulers.yaml ) url=https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.42.0/example/prometheus-operator-crd/ for i in ${crd[@]}; do kubectl apply -f $url/$i done } disable_unset () { read yaml # disable ldap for grafana [ -z "$grafana_ldap_toml" ] && \ echo "$yaml" | sed '/auth\.ldap:/,+1 s/true/false/; /ldap:/,+1 d' | read yaml # disable storage [ -z "$fileserver" ] && \ echo "$yaml" | sed '/prometheusSpec:/,+10d' $1 | read yaml echo $yaml } kubectl create ns $namespace install_prometheus_crds kubectl_apply $namespace "${charts[@]}" helm template \ -n $namespace \ -f values.yaml \ prometheus \ prometheus-community/kube-prometheus-stack \ | make_substitutions \ | kubectl -n $namespace -f -