k8s.io/test-infra@v0.0.0-20240520184403-27c6b4c223d8/config/prow/cluster/monitoring/mixins/Makefile (about) 1 # Copyright 2016 The Kubernetes Authors. 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 15 SHELL=/bin/bash -o pipefail 16 17 include ../../../../../hack/Makefile.gcloud.mk 18 19 PROJECT ?= k8s-prow 20 CLUSTER ?= prow 21 ZONE ?= us-central1-f 22 23 export PATH 24 25 expose-gobin: 26 $(eval PATH=${PATH}:${GOPATH}/bin) 27 28 grafana-dashboards: install clean-dashboard-out 29 @mkdir -p dashboards_out 30 @for input in $(shell ls grafana_dashboards); do \ 31 if [[ ! $${input} =~ .*\.jsonnet ]]; then \ 32 continue; \ 33 fi; \ 34 output="$${input%.*}.json"; \ 35 echo "Generating $${output} from $${input} ..."; \ 36 jsonnet -J vendor/ -J lib/ "grafana_dashboards/$${input}" > "./dashboards_out/$${output}"; \ 37 done 38 39 prow_prometheusrule.yaml: install clean-prometheus-out 40 @mkdir -p prometheus_out 41 @echo "Generating prow_prometheusrule.yaml ..." 42 jsonnet -J lib/ ./prometheus/prow_prometheusrule.jsonnet | gojsontoyaml > prometheus_out/$@ 43 44 apply-configmaps: get-cluster-credentials grafana-dashboards 45 @for input in $(shell ls dashboards_out); do \ 46 if [[ ! $${input} =~ .*\.json ]]; then \ 47 continue; \ 48 fi; \ 49 dashboard_name="grafana-dashboard-$${input%.*}"; \ 50 echo "Generating dashboard $${dashboard_name} from $${input} ..."; \ 51 kubectl create configmap -n prow-monitoring "$${dashboard_name}" --from-file="$${input}=dashboards_out/$${input}" --dry-run -o yaml | kubectl apply -f -; \ 52 done 53 54 apply-prow-prometheusrule: get-cluster-credentials prow_prometheusrule.yaml 55 kubectl apply -f prometheus_out/ 56 57 apply: apply-configmaps apply-prow-prometheusrule clean 58 59 clean-dashboard-out: 60 rm -rfv ./dashboards_out/*.json 61 62 clean-prometheus-out: 63 rm -rfv ./prometheus_out/*.json 64 rm -rfv ./prometheus_out/*.yaml 65 66 clean: clean-dashboard-out clean-prometheus-out 67 68 install: expose-gobin 69 @if ! command -v jsonnet>/dev/null; then \ 70 echo "Install jsonnet"; \ 71 go install github.com/google/go-jsonnet/cmd/jsonnet@v0.17.0; \ 72 fi 73 @ if ! command -v gojsontoyaml>/dev/null; then \ 74 echo "Install gojsontoyaml"; \ 75 go install github.com/brancz/gojsontoyaml@v0.1.0; \ 76 fi 77 78 .PHONY: expose-gobin grafana-dashboards prow_prometheusrule.yaml apply-configmaps apply-prow-prometheusrule apply clean-dashboard-out clean-prometheus-out clean install