From 92594c637ed836ce95208aedea71259ce195e323 Mon Sep 17 00:00:00 2001 From: Abhilash Shetty Date: Mon, 23 Sep 2024 01:05:46 +0530 Subject: [PATCH 1/3] chore(monitoring): removing unused jsonnet modules Signed-off-by: Abhilash Shetty chore(monitoring): bump chart version Signed-off-by: Abhilash Shetty chore(monitoring): update github wf Signed-off-by: Abhilash Shetty --- .github/workflows/jsonnet-lint.yml | 4 +- deploy/charts/Chart.yaml | 4 +- jsonnet/Makefile | 51 ------- jsonnet/README.md | 35 ----- jsonnet/addons/dashboard-cm.libsonnet | 20 --- jsonnet/addons/podMonitors.libsonnet | 12 -- jsonnet/addons/prometheusRules.libsonnet | 27 ---- jsonnet/addons/serviceMonitors.libsonnet | 12 -- jsonnet/buildscripts/build.sh | 22 --- jsonnet/buildscripts/go.mod | 11 -- jsonnet/buildscripts/go.sum | 61 -------- jsonnet/buildscripts/tools.go | 15 -- jsonnet/config.libsonnet | 119 ---------------- jsonnet/jsonnetfile.json | 15 -- jsonnet/jsonnetfile.lock.json | 171 ----------------------- jsonnet/lib/utils.libsonnet | 59 -------- jsonnet/main.jsonnet | 38 ----- 17 files changed, 4 insertions(+), 672 deletions(-) delete mode 100644 jsonnet/Makefile delete mode 100644 jsonnet/README.md delete mode 100644 jsonnet/addons/dashboard-cm.libsonnet delete mode 100644 jsonnet/addons/podMonitors.libsonnet delete mode 100644 jsonnet/addons/prometheusRules.libsonnet delete mode 100644 jsonnet/addons/serviceMonitors.libsonnet delete mode 100755 jsonnet/buildscripts/build.sh delete mode 100644 jsonnet/buildscripts/go.mod delete mode 100644 jsonnet/buildscripts/go.sum delete mode 100644 jsonnet/buildscripts/tools.go delete mode 100644 jsonnet/config.libsonnet delete mode 100644 jsonnet/jsonnetfile.json delete mode 100644 jsonnet/jsonnetfile.lock.json delete mode 100644 jsonnet/lib/utils.libsonnet delete mode 100644 jsonnet/main.jsonnet diff --git a/.github/workflows/jsonnet-lint.yml b/.github/workflows/jsonnet-lint.yml index c123e96..feb0ec0 100644 --- a/.github/workflows/jsonnet-lint.yml +++ b/.github/workflows/jsonnet-lint.yml @@ -23,8 +23,8 @@ jobs: - name: Jsonnet formatter run: | - cd jsonnet && make --always-make fmt + cd jsonnet/openebs-mixin && make --always-make fmt - name: Jsonnet linter run: | - cd jsonnet && make --always-make lint + cd jsonnet/openebs-mixin && make --always-make lint diff --git a/deploy/charts/Chart.yaml b/deploy/charts/Chart.yaml index 457e690..62134b5 100644 --- a/deploy/charts/Chart.yaml +++ b/deploy/charts/Chart.yaml @@ -22,12 +22,12 @@ keywords: # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 4.0.0 +version: 4.0.1 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. -appVersion: 4.0.0 +appVersion: 4.0.1 dependencies: - name: kube-prometheus-stack diff --git a/jsonnet/Makefile b/jsonnet/Makefile deleted file mode 100644 index 8d8c065..0000000 --- a/jsonnet/Makefile +++ /dev/null @@ -1,51 +0,0 @@ -SHELL=/usr/bin/env bash -o pipefail - -BIN_DIR?=$(shell pwd)/tmp/bin - -EMBEDMD_BIN=$(BIN_DIR)/embedmd -JB_BIN=$(BIN_DIR)/jb -GOJSONTOYAML_BIN=$(BIN_DIR)/gojsontoyaml -JSONNET_BIN=$(BIN_DIR)/jsonnet -JSONNETLINT_BIN=$(BIN_DIR)/jsonnet-lint -JSONNETFMT_BIN=$(BIN_DIR)/jsonnetfmt -KUBECONFORM_BIN=$(BIN_DIR)/kubeconform -TOOLING=$(EMBEDMD_BIN) $(JB_BIN) $(GOJSONTOYAML_BIN) $(JSONNET_BIN) $(JSONNETLINT_BIN) $(JSONNETFMT_BIN) $(KUBECONFORM_BIN) - -JSONNETFMT_ARGS=-n 2 --max-blank-lines 2 --string-style s --comment-style s - -KUBE_VERSION?="1.20.0" - -all: lint fmt generate - -.PHONY: clean -clean: - # Remove all files and directories ignored by git. - git clean -Xfd . - -.PHONY: generate -generate: manifests - -manifests: main.jsonnet $(GOJSONTOYAML_BIN) vendor buildscripts/build.sh - ./buildscripts/build.sh $< - -vendor: $(JB_BIN) jsonnetfile.json jsonnetfile.lock.json - rm -rf vendor - $(JB_BIN) install - -.PHONY: fmt -fmt: $(JSONNETFMT_BIN) - find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \ - xargs -n 1 -- $(JSONNETFMT_BIN) $(JSONNETFMT_ARGS) -i - -.PHONY: lint -lint: $(JSONNETLINT_BIN) vendor - find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \ - xargs -n 1 -- $(JSONNETLINT_BIN) -J vendor - - -$(BIN_DIR): - mkdir -p $(BIN_DIR) - -$(TOOLING): $(BIN_DIR) - @echo Installing tools from buildscripts/tools.go - @cd buildscripts && cat tools.go | grep _ | awk -F'"' '{print $$2}' | xargs -tI % go build -modfile=go.mod -o $(BIN_DIR) % diff --git a/jsonnet/README.md b/jsonnet/README.md deleted file mode 100644 index a14b628..0000000 --- a/jsonnet/README.md +++ /dev/null @@ -1,35 +0,0 @@ -# OpenEBS Monitoring -This repository collects Kubernetes manifests, Grafana dashboards, and Prometheus rules to monitor openebs with the help of kube-prometheus stack. - -The content of this project is written in jsonnet. This project could both be described as a package as well as a library. - - -## Generate manifests - -1. Clone the repo: - - ``` - $ git clone https://github.com/openebs/monitoring - $ cd monitoring/jsonnet - ``` - -2. Generate the manifests: - - ``` - $ make generate - ``` - - The files in `manifests/` are the yamls that have to be applied on the kubernetes cluster. - -3. Apply the kube-prometheus stack and openebs monitoring addons: - The previous step has generated a bunch of manifest files in the `manifests/` directory. Now simply use kubectl to install Prometheus and Grafana as per your configuration: - - ``` - # Apply kube-prometheus stack yamls - $ kubectl apply -f manifests/setup - $ kubectl apply -f manifests/ - - # Apply the openebs monitoring addons - $ kubectl apply -f manifests/openebs-addons - - ``` diff --git a/jsonnet/addons/dashboard-cm.libsonnet b/jsonnet/addons/dashboard-cm.libsonnet deleted file mode 100644 index b8cf666..0000000 --- a/jsonnet/addons/dashboard-cm.libsonnet +++ /dev/null @@ -1,20 +0,0 @@ -local dashboards = (import '../config.libsonnet').openebsMixin.grafanaDashboards; -local utils = import '../lib/utils.libsonnet'; -local config = import '../config.libsonnet'; - - -{ - // dashboards configMap yamls for different cas types. - grafanaDashboards: { - - [if config._config.openebsMonitoringAddon[monitoringAddon].enabled && config._config.openebsMonitoringAddon[monitoringAddon].installDashboards then name]: - - utils.ConfigMap('grafana-dashboard-' + std.asciiLower(std.strReplace(name, '.json', ''))) { - data: { [name]: std.manifestJson(dashboards[monitoringAddon][name]) }, - - } - - for monitoringAddon in std.objectFields(config._config.openebsMonitoringAddon) - for name in std.objectFields(dashboards[monitoringAddon]) - }, -} diff --git a/jsonnet/addons/podMonitors.libsonnet b/jsonnet/addons/podMonitors.libsonnet deleted file mode 100644 index ec49653..0000000 --- a/jsonnet/addons/podMonitors.libsonnet +++ /dev/null @@ -1,12 +0,0 @@ -local config = import '../config.libsonnet'; -local oc = import '../lib/utils.libsonnet'; - -{ - // PodMonitor yamls for different cas types - podMonitors: - { - [if config._config.openebsMonitoringAddon[monitoringAddon].enabled && config._config.openebsMonitoringAddon[monitoringAddon].podMonitor.enabled then monitoringAddon]: - oc.PodMonitor(std.asciiLower(monitoringAddon), monitoringAddon) - for monitoringAddon in std.objectFields(config._config.openebsMonitoringAddon) - }, -} diff --git a/jsonnet/addons/prometheusRules.libsonnet b/jsonnet/addons/prometheusRules.libsonnet deleted file mode 100644 index f0b66a1..0000000 --- a/jsonnet/addons/prometheusRules.libsonnet +++ /dev/null @@ -1,27 +0,0 @@ -local prometheusRules = (import '../config.libsonnet').openebsMixin.rules; -local utils = import '../lib/utils.libsonnet'; -local config = import '../config.libsonnet'; - -{ - // PrometheusRule yamls for different cas types - prometheusRules: - { - [if config.openebsMixin._config.alertRules[monitoringAddon] then monitoringAddon]: - - utils.PrometheusRule(std.asciiLower(monitoringAddon)) { - spec+: { - groups: prometheusRules[monitoringAddon].groups, - }, - } - - for monitoringAddon in std.objectFields(config._config.openebsMonitoringAddon) - - } + - { [if config.openebsMixin._config.alertRules.volume then 'volume']: - - utils.PrometheusRule(std.asciiLower('volume')) { - spec+: { - groups: prometheusRules.volume.groups, - }, - } }, -} diff --git a/jsonnet/addons/serviceMonitors.libsonnet b/jsonnet/addons/serviceMonitors.libsonnet deleted file mode 100644 index bbe9b27..0000000 --- a/jsonnet/addons/serviceMonitors.libsonnet +++ /dev/null @@ -1,12 +0,0 @@ -local config = import '../config.libsonnet'; -local oc = import '../lib/utils.libsonnet'; - -{ - // ServiceMonitor yamls for different cas types - serviceMonitors: - { - [if config._config.openebsMonitoringAddon[monitoringAddon].enabled && config._config.openebsMonitoringAddon[monitoringAddon].serviceMonitor.enabled then monitoringAddon]: - oc.ServiceMonitor(std.asciiLower(monitoringAddon), monitoringAddon) - for monitoringAddon in std.objectFields(config._config.openebsMonitoringAddon) - }, -} diff --git a/jsonnet/buildscripts/build.sh b/jsonnet/buildscripts/build.sh deleted file mode 100755 index d9e7a56..0000000 --- a/jsonnet/buildscripts/build.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -# This script uses arg $1 (name of *.jsonnet file to use) to generate the manifests/*.yaml files. - -set -e -set -x -# only exit with zero if all commands of the pipeline exit successfully -set -o pipefail - -# Make sure to use project tooling -PATH="$(pwd)/tmp/bin:${PATH}" - -# Make sure to start with a clean 'manifests' dir -rm -rf manifests -mkdir -p manifests/setup -mkdir -p manifests/openebs-addons - -# Calling gojsontoyaml is optional, but we would like to generate yaml, not json -jsonnet -J vendor -m manifests "${1-main.jsonnet}" | xargs -I{} sh -c 'cat {} | gojsontoyaml > {}.yaml' -- {} - -# Make sure to remove json files -find manifests -type f ! -name '*.yaml' -delete diff --git a/jsonnet/buildscripts/go.mod b/jsonnet/buildscripts/go.mod deleted file mode 100644 index 07b37e9..0000000 --- a/jsonnet/buildscripts/go.mod +++ /dev/null @@ -1,11 +0,0 @@ -module _ // go.mod created for tooling dependencies - -go 1.15 - -require ( - github.com/brancz/gojsontoyaml v0.0.0-20200602132005-3697ded27e8c - github.com/campoy/embedmd v1.0.0 - github.com/google/go-jsonnet v0.17.1-0.20210101181740-31d71aaccda6 // 7 commits after 0.17.0. Needed by jsonnet linter - github.com/jsonnet-bundler/jsonnet-bundler v0.4.0 - github.com/yannh/kubeconform v0.4.7 -) diff --git a/jsonnet/buildscripts/go.sum b/jsonnet/buildscripts/go.sum deleted file mode 100644 index 86874c2..0000000 --- a/jsonnet/buildscripts/go.sum +++ /dev/null @@ -1,61 +0,0 @@ -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A= -github.com/brancz/gojsontoyaml v0.0.0-20200602132005-3697ded27e8c h1:hb6WqfcKQZlNx/vahy51SaIvKnoXD5609Nm0PC4msEM= -github.com/brancz/gojsontoyaml v0.0.0-20200602132005-3697ded27e8c/go.mod h1:+00lOjYXPgMfxHVPvg9GDtc3BX5Xh5aFpB4gMB8gfMo= -github.com/campoy/embedmd v1.0.0 h1:V4kI2qTJJLf4J29RzI/MAt2c3Bl4dQSYPuflzwFH2hY= -github.com/campoy/embedmd v1.0.0/go.mod h1:oxyr9RCiSXg0M3VJ3ks0UGfp98BpSSGr0kpiX3MzVl8= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= -github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= -github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/google/go-jsonnet v0.17.1-0.20210101181740-31d71aaccda6 h1:91EupyycmO5ctzKuWEZ9nX0Cal1NveMiWcXxmRtLyLQ= -github.com/google/go-jsonnet v0.17.1-0.20210101181740-31d71aaccda6/go.mod h1:sOcuej3UW1vpPTZOr8L7RQimqai1a57bt5j22LzGZCw= -github.com/jsonnet-bundler/jsonnet-bundler v0.4.0 h1:4BKZ6LDqPc2wJDmaKnmYD/vDjUptJtnUpai802MibFc= -github.com/jsonnet-bundler/jsonnet-bundler v0.4.0/go.mod h1:/by7P/OoohkI3q4CgSFqcoFsVY+IaNbzOVDknEsKDeU= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= -github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-isatty v0.0.6/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.11 h1:FxPOTFNqGkuDUGi3H/qkUbQO4ZiBa2brKq5r0l8TGeM= -github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= -github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= -github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= -github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= -github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= -github.com/yannh/kubeconform v0.4.7 h1:ExAjZYd6D0WnG/Eq/IRxvTebPbARh6e6M96Pq8Xy5u0= -github.com/yannh/kubeconform v0.4.7/go.mod h1:lhkEiaDOtSewHGGZ8iR2iiTC0CSnR7xbMEtyL4bm4rE= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190310054646-10058d7d4faa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= -sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= diff --git a/jsonnet/buildscripts/tools.go b/jsonnet/buildscripts/tools.go deleted file mode 100644 index 288ad57..0000000 --- a/jsonnet/buildscripts/tools.go +++ /dev/null @@ -1,15 +0,0 @@ -//+build tools - -// Package tools tracks dependencies for tools that used in the build process. -// See https://github.com/golang/go/wiki/Modules -package tools - -import ( - _ "github.com/brancz/gojsontoyaml" - _ "github.com/campoy/embedmd" - _ "github.com/google/go-jsonnet/cmd/jsonnet" - _ "github.com/google/go-jsonnet/cmd/jsonnet-lint" - _ "github.com/google/go-jsonnet/cmd/jsonnetfmt" - _ "github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb" - _ "github.com/yannh/kubeconform/cmd/kubeconform" -) diff --git a/jsonnet/config.libsonnet b/jsonnet/config.libsonnet deleted file mode 100644 index a224e0b..0000000 --- a/jsonnet/config.libsonnet +++ /dev/null @@ -1,119 +0,0 @@ -{ - // import kube-prometheus and override configurations - kp: - (import 'kube-prometheus/main.libsonnet') + - (import 'kube-prometheus/addons/all-namespaces.libsonnet') + - // Uncomment the following imports to enable its patches - // (import 'kube-prometheus/addons/anti-affinity.libsonnet') + - // (import 'kube-prometheus/addons/managed-cluster.libsonnet') + - (import 'kube-prometheus/addons/node-ports.libsonnet') + - // (import 'kube-prometheus/addons/static-etcd.libsonnet') + - // (import 'kube-prometheus/addons/custom-metrics.libsonnet') + - // (import 'kube-prometheus/addons/external-metrics.libsonnet') + - { - values+:: { - common+: { - namespace: $._config.openebsMonitoring.namespace, - }, - }, - }, - - // import openebs-mixin and override configurations - openebsMixin: (import './openebs-mixin/mixin.libsonnet') { - _config+:: { - dashboards+: { - lvmLocalPV: $._config.openebsMonitoringAddon.lvmLocalPV.dashboards, - zfsLocalPV: $._config.openebsMonitoringAddon.zfsLocalPV.dashboards, - mayastor: $._config.openebsMonitoringAddon.mayastor.dashboards, - }, - alertRules+: { - lvmLocalPV: $._config.openebsMonitoringAddon.lvmLocalPV.alertRules, - zfsLocalPV: $._config.openebsMonitoringAddon.zfsLocalPV.alertRules, - mayastor: $._config.openebsMonitoringAddon.mayastor.alertRules, - }, - }, - }, - - // Template function for ServiceMonitor - local serviceMonitor(port, path, selectorName) = { - // Endpoints of the selected service to be monitored - endpoints: { - - // Name of the endpoint's service port - port: port, - - // HTTP path to scrape for metrics - path: path, - }, - // Label selector for services to which this ServiceMonitor applies - selector: { - matchLabels: selectorName, - }, - // Namespaces from which services are selected - namespaceSelector: { - any: true, - }, - }, - - // Configuration for openebs monitoring - _config+:: { - openebsMonitoring: { - namespace: 'openebs', - }, - // Configuration for different cas types. - openebsMonitoringAddon: { - mayastor: { - // To generate manifests for mayastor. If set, manifests will be generated. - enabled: true, - // To generate dashboards configMap yamls. If set, dashboards will be appended in grafana-dashboardDefinition yaml. - dashboards: true, - // To generate prometheusRule yamls. If set, prometheusRule will be generated. - alertRules: false, - // ServiceMonitor configuration - serviceMonitor: serviceMonitor('metrics', '/metrics', { - app: 'metrics-exporter-io-engine', - }) { - enabled: true, - }, - // PodMonitor configuration - podMonitor: { - enabled: false, - }, - }, - lvmLocalPV: { - // To generate manifests for lvmLocalPV. If set, manifests will be generated for lvm-localpv. - enabled: true, - // To generate dashboards configMap yamls. If set, dashboards will be appended in grafana-dashboardDefinition yaml. - dashboards: true, - // To generate prometheusRule yamls. If set, prometheusRule will be generated. - alertRules: true, - // ServiceMonitor configuration - serviceMonitor: serviceMonitor('metrics', '/metrics', { - name: 'openebs-lvm-node', - }) { - enabled: true, - }, - // PodMonitor configuration - podMonitor: { - enabled: false, - }, - }, - zfsLocalPV: { - // To generate manifests for zfs localpv. If set, manifests will be generated. - enabled: true, - // To generate dashboards configMap yamls. If set, dashboards will be appended in grafana-dashboardDefinition yaml. - dashboards: true, - // To generate prometheusRule yamls. If set, prometheusRule will be generated. - alertRules: false, - // ServiceMonitor configuration - serviceMonitor: { - enabled: false, - }, - // PodMonitor configuration - podMonitor: { - enabled: false, - }, - }, - }, - }, -} diff --git a/jsonnet/jsonnetfile.json b/jsonnet/jsonnetfile.json deleted file mode 100644 index 604e24b..0000000 --- a/jsonnet/jsonnetfile.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "version": 1, - "dependencies": [ - { - "source": { - "git": { - "remote": "https://github.com/prometheus-operator/kube-prometheus.git", - "subdir": "jsonnet/kube-prometheus" - } - }, - "version": "release-0.8" - } - ], - "legacyImports": true -} diff --git a/jsonnet/jsonnetfile.lock.json b/jsonnet/jsonnetfile.lock.json deleted file mode 100644 index 77e4e95..0000000 --- a/jsonnet/jsonnetfile.lock.json +++ /dev/null @@ -1,171 +0,0 @@ -{ - "version": 1, - "dependencies": [ - { - "source": { - "git": { - "remote": "https://github.com/brancz/kubernetes-grafana.git", - "subdir": "grafana" - } - }, - "version": "8ea4e7bc04b1bf5e9bd99918ca28c6271b42be0e", - "sum": "muenICtKXABk6MZZHCZD2wCbmtiE96GwWRMGa1Rg+wA=" - }, - { - "source": { - "git": { - "remote": "https://github.com/etcd-io/etcd.git", - "subdir": "contrib/mixin" - } - }, - "version": "562d645ac923388ff5b8d270b0536764d34b0e0f", - "sum": "W/Azptf1PoqjyMwJON96UY69MFugDA4IAYiKURscryc=" - }, - { - "source": { - "git": { - "remote": "https://github.com/grafana/grafonnet-lib.git", - "subdir": "grafonnet" - } - }, - "version": "3082bfca110166cd69533fa3c0875fdb1b68c329", - "sum": "4/sUV0Kk+o8I+wlYxL9R6EPhL/NiLfYHk+NXlU64RUk=" - }, - { - "source": { - "git": { - "remote": "https://github.com/grafana/jsonnet-libs.git", - "subdir": "grafana-builder" - } - }, - "version": "81696e4d5fda54c25b7129eadade2976e3f19dc5", - "sum": "GRf2GvwEU4jhXV+JOonXSZ4wdDv8mnHBPCQ6TUVd+g8=" - }, - { - "source": { - "git": { - "remote": "https://github.com/ksonnet/ksonnet-lib.git", - "subdir": "" - } - }, - "version": "0d2f82676817bbf9e4acf6495b2090205f323b9f", - "sum": "h28BXZ7+vczxYJ2sCt8JuR9+yznRtU/iA6DCpQUrtEg=", - "name": "ksonnet" - }, - { - "source": { - "git": { - "remote": "https://github.com/kubernetes-monitoring/kubernetes-mixin.git", - "subdir": "" - } - }, - "version": "e15ab56a4eea721d1e958888fd13c4b95af4d17d", - "sum": "voj/Pfit89sI+xBCyFV8oEV4UgnsaJZ2VrOU7s9jZe8=" - }, - { - "source": { - "git": { - "remote": "https://github.com/kubernetes-monitoring/kubernetes-mixin.git", - "subdir": "lib/promgrafonnet" - } - }, - "version": "b710a868a95621aa93e0b661954f63f4db82aaea", - "sum": "zv7hXGui6BfHzE9wPatHI/AGZa4A2WKo6pq7ZdqBsps=" - }, - { - "source": { - "git": { - "remote": "https://github.com/kubernetes/kube-state-metrics.git", - "subdir": "jsonnet/kube-state-metrics" - } - }, - "version": "b1889aa1561ee269f628e2b9659155e7714dbbf0", - "sum": "S5qI+PJUdNeYOv76jH5nxwYS9N6U7CRxvyuB1wI4cTE=" - }, - { - "source": { - "git": { - "remote": "https://github.com/kubernetes/kube-state-metrics.git", - "subdir": "jsonnet/kube-state-metrics-mixin" - } - }, - "version": "b1889aa1561ee269f628e2b9659155e7714dbbf0", - "sum": "Yf8mNAHrV1YWzrdV8Ry5dJ8YblepTGw3C0Zp10XIYLo=" - }, - { - "source": { - "git": { - "remote": "https://github.com/prometheus-operator/kube-prometheus.git", - "subdir": "jsonnet/kube-prometheus" - } - }, - "version": "e8b58191b586d23c3a19bbf045c78630b568b29b", - "sum": "e/4y/phKZ+cCDPCW6WAwSaO9kJk1TyyDwcR+/f9qkrQ=" - }, - { - "source": { - "git": { - "remote": "https://github.com/prometheus-operator/prometheus-operator.git", - "subdir": "jsonnet/mixin" - } - }, - "version": "b7ca32169844f0b5143f3e5e318fc05fa025df18", - "sum": "6reUygVmQrLEWQzTKcH8ceDbvM+2ztK3z2VBR2K2l+U=", - "name": "prometheus-operator-mixin" - }, - { - "source": { - "git": { - "remote": "https://github.com/prometheus-operator/prometheus-operator.git", - "subdir": "jsonnet/prometheus-operator" - } - }, - "version": "b7ca32169844f0b5143f3e5e318fc05fa025df18", - "sum": "MRwyChXdKG3anL2OWpbUu3qWc97w9J6YsjUWjLFQyB0=" - }, - { - "source": { - "git": { - "remote": "https://github.com/prometheus/alertmanager.git", - "subdir": "doc/alertmanager-mixin" - } - }, - "version": "99f64e944b1043c790784cf5373c8fb349816fc4", - "sum": "V8jcZQ1Qrlm7AQ6wjbuQQsacPb0NvrcZovKyplmzW5w=", - "name": "alertmanager" - }, - { - "source": { - "git": { - "remote": "https://github.com/prometheus/node_exporter.git", - "subdir": "docs/node-mixin" - } - }, - "version": "b597c1244d7bef49e6f3359c87a56dd7707f6719", - "sum": "cZTNXQMUCLB5FGYpMn845dcqGdkcYt58qCqOFIV/BoQ=" - }, - { - "source": { - "git": { - "remote": "https://github.com/prometheus/prometheus.git", - "subdir": "documentation/prometheus-mixin" - } - }, - "version": "6eeded0fdf760e81af75d9c44ce539ab77da4505", - "sum": "VK0c3sQ3ksiM6JQsAVfWmL5NbzGv9llMfXFNXfFdJ+A=", - "name": "prometheus" - }, - { - "source": { - "git": { - "remote": "https://github.com/thanos-io/thanos.git", - "subdir": "mixin" - } - }, - "version": "ba6c5c4726ff52807c7383c68f2159b1af7980bb", - "sum": "XP3uq7xcfKHsnWsz1v992csZhhZR3jQma6hFOfSViTs=", - "name": "thanos-mixin" - } - ], - "legacyImports": false -} diff --git a/jsonnet/lib/utils.libsonnet b/jsonnet/lib/utils.libsonnet deleted file mode 100644 index 50794a9..0000000 --- a/jsonnet/lib/utils.libsonnet +++ /dev/null @@ -1,59 +0,0 @@ -local config = import '../config.libsonnet'; -{ - // Template function to create object for kubernetes. - _Object(apiVersion, kind, name):: { - apiVersion: apiVersion, - kind: kind, - metadata: { - name: name, - labels: { name: name }, - annotations: {}, - namespace: config._config.openebsMonitoring.namespace, - }, - }, - - // Template function to create ServiceMonitor. - ServiceMonitor(name, monitoringAddon): $._Object('monitoring.coreos.com/v1', 'ServiceMonitor', name) { - local svm = self, - sc:: { - st: config._config.openebsMonitoringAddon, - }, - spec: { - endpoints: [ - svm.sc.st[monitoringAddon].serviceMonitor.endpoints, - ], - namespaceSelector: svm.sc.st[monitoringAddon].serviceMonitor.namespaceSelector, - selector: svm.sc.st[monitoringAddon].serviceMonitor.selector, - }, - }, - - // Template function to create PodMonitor. - PodMonitor(name, monitoringAddon): $._Object('monitoring.coreos.com/v1', 'PodMonitor', name) { - spec: { - podMetricsEndpoints: [ - config._config.openebsMonitoringAddon[monitoringAddon].podMonitor.podMetricsEndpoints, - ], - namespaceSelector: config._config.openebsMonitoringAddon[monitoringAddon].podMonitor.namespaceSelector, - selector: config._config.openebsMonitoringAddon[monitoringAddon].podMonitor.selector, - }, - }, - - // Template function to create ConfigMap. - ConfigMap(name): $._Object('v1', 'ConfigMap', name) { - metadata+: { - labels+: { - grafana_dashboard: '1', - }, - }, - data: {}, - }, - - // Template function to create PrometheusRule. - PrometheusRule(name): $._Object('monitoring.coreos.com/v1', 'PrometheusRule', name) { - metadata+: { - labels+: config.kp.values.common.ruleLabels, - }, - spec: { - }, - }, -} diff --git a/jsonnet/main.jsonnet b/jsonnet/main.jsonnet deleted file mode 100644 index b2cea3a..0000000 --- a/jsonnet/main.jsonnet +++ /dev/null @@ -1,38 +0,0 @@ -local podMonitors = import './addons/podMonitors.libsonnet'; -local rules = import './addons/prometheusRules.libsonnet'; -local serviceMonitor = import './addons/serviceMonitors.libsonnet'; -local config = import './config.libsonnet'; -local openebsMixin = config.openebsMixin; - -local kp = - config.kp { - values+:: { - grafana+: { - dashboards+: openebsMixin.grafanaDashboards, - }, - prometheus+: { - namespaces: [], - }, - }, - }; - -{ 'setup/0namespace-namespace': kp.kubePrometheus.namespace } + -{ - ['setup/prometheus-operator-' + name]: kp.prometheusOperator[name] - for name in std.filter((function(name) name != 'serviceMonitor' && name != 'prometheusRule'), std.objectFields(kp.prometheusOperator)) -} + -// serviceMonitor and prometheusRule are separated so that they can be created after the CRDs are ready -{ 'prometheus-operator-serviceMonitor': kp.prometheusOperator.serviceMonitor } + -{ 'prometheus-operator-prometheusRule': kp.prometheusOperator.prometheusRule } + -{ 'kube-prometheus-prometheusRule': kp.kubePrometheus.prometheusRule } + -{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } + -{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } + -{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } + -{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } + -{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } + - - -// servicemonitor, podmonitor and prometheusrules for different casTypes of openebs -{ ['openebs-addons/openebs-servicemonitor-' + casType]: serviceMonitor.serviceMonitors[casType] for casType in std.objectFields(serviceMonitor.serviceMonitors) } + -{ ['openebs-addons/openebs-podmonitor-' + casType]: podMonitors.podMonitors[casType] for casType in std.objectFields(podMonitors.podMonitors) } + -{ ['openebs-addons/openebs-rule-' + name]: rules.prometheusRules[name] for name in std.objectFields(rules.prometheusRules) } From 8ee3f91f900cbcb0f2ef0d56cee9e0a46b1a5f97 Mon Sep 17 00:00:00 2001 From: w3aman Date: Thu, 5 Sep 2024 21:37:34 +0530 Subject: [PATCH 2/3] add check for subcharts enable in templates Signed-off-by: w3aman chore(monitoring): few more refactoring --- .github/workflows/jsonnet-lint.yml | 4 +- deploy/charts/templates/_helpers.tpl | 5 +- deploy/charts/values.yaml | 6 +- jsonnet/Makefile | 45 +++++++ jsonnet/buildscripts/go.mod | 27 +++++ jsonnet/buildscripts/go.sum | 53 +++++++++ jsonnet/buildscripts/tools.go | 15 +++ jsonnet/jsonnetfile.json | 15 +++ jsonnet/jsonnetfile.lock.json | 171 +++++++++++++++++++++++++++ 9 files changed, 335 insertions(+), 6 deletions(-) create mode 100644 jsonnet/Makefile create mode 100644 jsonnet/buildscripts/go.mod create mode 100644 jsonnet/buildscripts/go.sum create mode 100644 jsonnet/buildscripts/tools.go create mode 100644 jsonnet/jsonnetfile.json create mode 100644 jsonnet/jsonnetfile.lock.json diff --git a/.github/workflows/jsonnet-lint.yml b/.github/workflows/jsonnet-lint.yml index feb0ec0..c123e96 100644 --- a/.github/workflows/jsonnet-lint.yml +++ b/.github/workflows/jsonnet-lint.yml @@ -23,8 +23,8 @@ jobs: - name: Jsonnet formatter run: | - cd jsonnet/openebs-mixin && make --always-make fmt + cd jsonnet && make --always-make fmt - name: Jsonnet linter run: | - cd jsonnet/openebs-mixin && make --always-make lint + cd jsonnet && make --always-make lint diff --git a/deploy/charts/templates/_helpers.tpl b/deploy/charts/templates/_helpers.tpl index bfa4452..7f8c85c 100644 --- a/deploy/charts/templates/_helpers.tpl +++ b/deploy/charts/templates/_helpers.tpl @@ -80,5 +80,8 @@ Usage: {{- range $subchart }} {{- $values = index $values . }} {{- end }} -{{- include $template (dict "Chart" (dict "Name" (last $subchart)) "Values" $values "Release" $dot.Release "Capabilities" $dot.Capabilities) }} +{{- if $values.enabled }} # Add this condition to check if the subchart is enabled + {{- include $template (dict "Chart" (dict "Name" (last $subchart)) "Values" $values "Release" $dot.Release "Capabilities" $dot.Capabilities) }} {{- end }} +{{- end }} + diff --git a/deploy/charts/values.yaml b/deploy/charts/values.yaml index 4e29900..f41d196 100644 --- a/deploy/charts/values.yaml +++ b/deploy/charts/values.yaml @@ -39,9 +39,9 @@ kube-prometheus-stack: ## Additional container arguments extraArgs: - - --collector.filesystem.ignored-mount-points=^/(dev|proc|sys|var/lib/docker/.+)($|/) - - --collector.filesystem.ignored-fs-types=^(tmpfs|autofs|binfmt_misc|cgroup|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|mqueue|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|sysfs|tracefs)$ - - --collector.diskstats.ignored-devices=^(ram|loop|fd|(h|s|v|xv)d[a-z]+|nvme\\d+n\\d+p)\\d+$ + - --collector.filesystem.mount-points-exclude=^/(dev|proc|sys|var/lib/docker/.+)($|/) + - --collector.filesystem.fs-types-exclude=^(tmpfs|autofs|binfmt_misc|cgroup|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|mqueue|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|sysfs|tracefs)$ + - --collector.diskstats.device-exclude=^(ram|loop|fd|sr|(h|s|v|xv)d[a-z]+|nvme\d+n\d+p|nvme\d+c\d+n)\d+$ prometheus: service: diff --git a/jsonnet/Makefile b/jsonnet/Makefile new file mode 100644 index 0000000..2f42934 --- /dev/null +++ b/jsonnet/Makefile @@ -0,0 +1,45 @@ +SHELL=/usr/bin/env bash -o pipefail + +BIN_DIR?=$(shell pwd)/tmp/bin + +EMBEDMD_BIN=$(BIN_DIR)/embedmd +JB_BIN=$(BIN_DIR)/jb +GOJSONTOYAML_BIN=$(BIN_DIR)/gojsontoyaml +JSONNET_BIN=$(BIN_DIR)/jsonnet +JSONNETLINT_BIN=$(BIN_DIR)/jsonnet-lint +JSONNETFMT_BIN=$(BIN_DIR)/jsonnetfmt +KUBECONFORM_BIN=$(BIN_DIR)/kubeconform +TOOLING=$(EMBEDMD_BIN) $(JB_BIN) $(GOJSONTOYAML_BIN) $(JSONNET_BIN) $(JSONNETLINT_BIN) $(JSONNETFMT_BIN) $(KUBECONFORM_BIN) + +JSONNETFMT_ARGS=-n 2 --max-blank-lines 2 --string-style s --comment-style s + +KUBE_VERSION?="1.20.0" + +all: lint fmt generate + +.PHONY: clean +clean: + # Remove all files and directories ignored by git. + git clean -Xfd . + +vendor: $(JB_BIN) jsonnetfile.json jsonnetfile.lock.json + rm -rf vendor + $(JB_BIN) install + +.PHONY: fmt +fmt: $(JSONNETFMT_BIN) + find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \ + xargs -n 1 -- $(JSONNETFMT_BIN) $(JSONNETFMT_ARGS) -i + +.PHONY: lint +lint: $(JSONNETLINT_BIN) vendor + find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \ + xargs -n 1 -- $(JSONNETLINT_BIN) -J vendor + + +$(BIN_DIR): + mkdir -p $(BIN_DIR) + +$(TOOLING): $(BIN_DIR) + @echo Installing tools from buildscripts/tools.go + @cd buildscripts && cat tools.go | grep _ | awk -F'"' '{print $$2}' | xargs -tI % go build -modfile=go.mod -o $(BIN_DIR) % diff --git a/jsonnet/buildscripts/go.mod b/jsonnet/buildscripts/go.mod new file mode 100644 index 0000000..2600c6e --- /dev/null +++ b/jsonnet/buildscripts/go.mod @@ -0,0 +1,27 @@ +module _ // go.mod created for tooling dependencies + +go 1.19 + +require ( + github.com/brancz/gojsontoyaml v0.1.0 + github.com/campoy/embedmd v1.0.0 + github.com/google/go-jsonnet v0.20.0 + github.com/jsonnet-bundler/jsonnet-bundler v0.4.0 + github.com/yannh/kubeconform v0.6.0 +) + +require ( + github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect + github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect + github.com/fatih/color v1.12.0 // indirect + github.com/ghodss/yaml v1.0.0 // indirect + github.com/mattn/go-colorable v0.1.8 // indirect + github.com/mattn/go-isatty v0.0.12 // indirect + github.com/pkg/errors v0.8.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/santhosh-tekuri/jsonschema/v5 v5.1.1 // indirect + golang.org/x/sys v0.1.0 // indirect + gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + sigs.k8s.io/yaml v1.2.0 // indirect +) diff --git a/jsonnet/buildscripts/go.sum b/jsonnet/buildscripts/go.sum new file mode 100644 index 0000000..dd4ddb4 --- /dev/null +++ b/jsonnet/buildscripts/go.sum @@ -0,0 +1,53 @@ +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/brancz/gojsontoyaml v0.1.0 h1:SdzR3+BCVOqaI42nFGTeaB7/2DgDM4fhuvRLqxatA8M= +github.com/brancz/gojsontoyaml v0.1.0/go.mod h1:+ycZY94+V11XZBUaDEsbLr3hPNS/ZPrDVKKNUg3Sgvg= +github.com/campoy/embedmd v1.0.0 h1:V4kI2qTJJLf4J29RzI/MAt2c3Bl4dQSYPuflzwFH2hY= +github.com/campoy/embedmd v1.0.0/go.mod h1:oxyr9RCiSXg0M3VJ3ks0UGfp98BpSSGr0kpiX3MzVl8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fatih/color v1.12.0 h1:mRhaKNwANqRgUBGKmnI5ZxEk7QXmjQeCcuYFMX2bfcc= +github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/google/go-jsonnet v0.20.0 h1:WG4TTSARuV7bSm4PMB4ohjxe33IHT5WVTrJSU33uT4g= +github.com/google/go-jsonnet v0.20.0/go.mod h1:VbgWF9JX7ztlv770x/TolZNGGFfiHEVx9G6ca2eUmeA= +github.com/jsonnet-bundler/jsonnet-bundler v0.4.0 h1:4BKZ6LDqPc2wJDmaKnmYD/vDjUptJtnUpai802MibFc= +github.com/jsonnet-bundler/jsonnet-bundler v0.4.0/go.mod h1:/by7P/OoohkI3q4CgSFqcoFsVY+IaNbzOVDknEsKDeU= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= +github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-isatty v0.0.6/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/santhosh-tekuri/jsonschema/v5 v5.1.1 h1:lEOLY2vyGIqKWUI9nzsOJRV3mb3WC9dXYORsLEUcoeY= +github.com/santhosh-tekuri/jsonschema/v5 v5.1.1/go.mod h1:FKdcjfQW6rpZSnxxUvEA5H/cDPdvJ/SZJQLWWXWGrZ0= +github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/yannh/kubeconform v0.6.0 h1:4Figo6t2OF8yNkC+cqa8qy20jcYY0LsJF0+p2klZZiU= +github.com/yannh/kubeconform v0.6.0/go.mod h1:4E6oaL+lh7KgCG2SaOabeeAFBkyKu5D9ab0OEekGcbs= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190310054646-10058d7d4faa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= +sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= diff --git a/jsonnet/buildscripts/tools.go b/jsonnet/buildscripts/tools.go new file mode 100644 index 0000000..288ad57 --- /dev/null +++ b/jsonnet/buildscripts/tools.go @@ -0,0 +1,15 @@ +//+build tools + +// Package tools tracks dependencies for tools that used in the build process. +// See https://github.com/golang/go/wiki/Modules +package tools + +import ( + _ "github.com/brancz/gojsontoyaml" + _ "github.com/campoy/embedmd" + _ "github.com/google/go-jsonnet/cmd/jsonnet" + _ "github.com/google/go-jsonnet/cmd/jsonnet-lint" + _ "github.com/google/go-jsonnet/cmd/jsonnetfmt" + _ "github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb" + _ "github.com/yannh/kubeconform/cmd/kubeconform" +) diff --git a/jsonnet/jsonnetfile.json b/jsonnet/jsonnetfile.json new file mode 100644 index 0000000..22689f4 --- /dev/null +++ b/jsonnet/jsonnetfile.json @@ -0,0 +1,15 @@ +{ + "version": 1, + "dependencies": [ + { + "source": { + "git": { + "remote": "https://github.com/prometheus-operator/kube-prometheus.git", + "subdir": "jsonnet/kube-prometheus" + } + }, + "version": "61.0.0" + } + ], + "legacyImports": true +} diff --git a/jsonnet/jsonnetfile.lock.json b/jsonnet/jsonnetfile.lock.json new file mode 100644 index 0000000..77e4e95 --- /dev/null +++ b/jsonnet/jsonnetfile.lock.json @@ -0,0 +1,171 @@ +{ + "version": 1, + "dependencies": [ + { + "source": { + "git": { + "remote": "https://github.com/brancz/kubernetes-grafana.git", + "subdir": "grafana" + } + }, + "version": "8ea4e7bc04b1bf5e9bd99918ca28c6271b42be0e", + "sum": "muenICtKXABk6MZZHCZD2wCbmtiE96GwWRMGa1Rg+wA=" + }, + { + "source": { + "git": { + "remote": "https://github.com/etcd-io/etcd.git", + "subdir": "contrib/mixin" + } + }, + "version": "562d645ac923388ff5b8d270b0536764d34b0e0f", + "sum": "W/Azptf1PoqjyMwJON96UY69MFugDA4IAYiKURscryc=" + }, + { + "source": { + "git": { + "remote": "https://github.com/grafana/grafonnet-lib.git", + "subdir": "grafonnet" + } + }, + "version": "3082bfca110166cd69533fa3c0875fdb1b68c329", + "sum": "4/sUV0Kk+o8I+wlYxL9R6EPhL/NiLfYHk+NXlU64RUk=" + }, + { + "source": { + "git": { + "remote": "https://github.com/grafana/jsonnet-libs.git", + "subdir": "grafana-builder" + } + }, + "version": "81696e4d5fda54c25b7129eadade2976e3f19dc5", + "sum": "GRf2GvwEU4jhXV+JOonXSZ4wdDv8mnHBPCQ6TUVd+g8=" + }, + { + "source": { + "git": { + "remote": "https://github.com/ksonnet/ksonnet-lib.git", + "subdir": "" + } + }, + "version": "0d2f82676817bbf9e4acf6495b2090205f323b9f", + "sum": "h28BXZ7+vczxYJ2sCt8JuR9+yznRtU/iA6DCpQUrtEg=", + "name": "ksonnet" + }, + { + "source": { + "git": { + "remote": "https://github.com/kubernetes-monitoring/kubernetes-mixin.git", + "subdir": "" + } + }, + "version": "e15ab56a4eea721d1e958888fd13c4b95af4d17d", + "sum": "voj/Pfit89sI+xBCyFV8oEV4UgnsaJZ2VrOU7s9jZe8=" + }, + { + "source": { + "git": { + "remote": "https://github.com/kubernetes-monitoring/kubernetes-mixin.git", + "subdir": "lib/promgrafonnet" + } + }, + "version": "b710a868a95621aa93e0b661954f63f4db82aaea", + "sum": "zv7hXGui6BfHzE9wPatHI/AGZa4A2WKo6pq7ZdqBsps=" + }, + { + "source": { + "git": { + "remote": "https://github.com/kubernetes/kube-state-metrics.git", + "subdir": "jsonnet/kube-state-metrics" + } + }, + "version": "b1889aa1561ee269f628e2b9659155e7714dbbf0", + "sum": "S5qI+PJUdNeYOv76jH5nxwYS9N6U7CRxvyuB1wI4cTE=" + }, + { + "source": { + "git": { + "remote": "https://github.com/kubernetes/kube-state-metrics.git", + "subdir": "jsonnet/kube-state-metrics-mixin" + } + }, + "version": "b1889aa1561ee269f628e2b9659155e7714dbbf0", + "sum": "Yf8mNAHrV1YWzrdV8Ry5dJ8YblepTGw3C0Zp10XIYLo=" + }, + { + "source": { + "git": { + "remote": "https://github.com/prometheus-operator/kube-prometheus.git", + "subdir": "jsonnet/kube-prometheus" + } + }, + "version": "e8b58191b586d23c3a19bbf045c78630b568b29b", + "sum": "e/4y/phKZ+cCDPCW6WAwSaO9kJk1TyyDwcR+/f9qkrQ=" + }, + { + "source": { + "git": { + "remote": "https://github.com/prometheus-operator/prometheus-operator.git", + "subdir": "jsonnet/mixin" + } + }, + "version": "b7ca32169844f0b5143f3e5e318fc05fa025df18", + "sum": "6reUygVmQrLEWQzTKcH8ceDbvM+2ztK3z2VBR2K2l+U=", + "name": "prometheus-operator-mixin" + }, + { + "source": { + "git": { + "remote": "https://github.com/prometheus-operator/prometheus-operator.git", + "subdir": "jsonnet/prometheus-operator" + } + }, + "version": "b7ca32169844f0b5143f3e5e318fc05fa025df18", + "sum": "MRwyChXdKG3anL2OWpbUu3qWc97w9J6YsjUWjLFQyB0=" + }, + { + "source": { + "git": { + "remote": "https://github.com/prometheus/alertmanager.git", + "subdir": "doc/alertmanager-mixin" + } + }, + "version": "99f64e944b1043c790784cf5373c8fb349816fc4", + "sum": "V8jcZQ1Qrlm7AQ6wjbuQQsacPb0NvrcZovKyplmzW5w=", + "name": "alertmanager" + }, + { + "source": { + "git": { + "remote": "https://github.com/prometheus/node_exporter.git", + "subdir": "docs/node-mixin" + } + }, + "version": "b597c1244d7bef49e6f3359c87a56dd7707f6719", + "sum": "cZTNXQMUCLB5FGYpMn845dcqGdkcYt58qCqOFIV/BoQ=" + }, + { + "source": { + "git": { + "remote": "https://github.com/prometheus/prometheus.git", + "subdir": "documentation/prometheus-mixin" + } + }, + "version": "6eeded0fdf760e81af75d9c44ce539ab77da4505", + "sum": "VK0c3sQ3ksiM6JQsAVfWmL5NbzGv9llMfXFNXfFdJ+A=", + "name": "prometheus" + }, + { + "source": { + "git": { + "remote": "https://github.com/thanos-io/thanos.git", + "subdir": "mixin" + } + }, + "version": "ba6c5c4726ff52807c7383c68f2159b1af7980bb", + "sum": "XP3uq7xcfKHsnWsz1v992csZhhZR3jQma6hFOfSViTs=", + "name": "thanos-mixin" + } + ], + "legacyImports": false +} From 1a97413171659e44db990638a9b4db618d9e615b Mon Sep 17 00:00:00 2001 From: Abhilash Shetty Date: Thu, 26 Sep 2024 09:34:57 +0000 Subject: [PATCH 3/3] chore(monitoring): adding nix package and readme generator Signed-off-by: Abhilash Shetty --- .github/workflows/jsonnet-lint.yml | 9 +- deploy/charts/README.md | 248 +++++++++++++-------------- deploy/charts/templates/_helpers.tpl | 2 +- jsonnet/Makefile | 21 +-- jsonnet/buildscripts/go.mod | 6 - jsonnet/buildscripts/go.sum | 9 - jsonnet/buildscripts/tools.go | 3 - jsonnet/jsonnetfile.json | 15 -- jsonnet/jsonnetfile.lock.json | 171 ------------------ nix/README.md | 14 ++ nix/lib/rust.nix | 31 ++++ nix/lib/sourcer.nix | 24 +++ nix/overlay.nix | 4 + nix/sources.json | 50 ++++++ nix/sources.nix | 144 ++++++++++++++++ scripts/generate-readme.sh | 16 ++ scripts/shell.nix | 21 +++ 17 files changed, 429 insertions(+), 359 deletions(-) delete mode 100644 jsonnet/jsonnetfile.json delete mode 100644 jsonnet/jsonnetfile.lock.json create mode 100644 nix/README.md create mode 100644 nix/lib/rust.nix create mode 100644 nix/lib/sourcer.nix create mode 100644 nix/overlay.nix create mode 100644 nix/sources.json create mode 100644 nix/sources.nix create mode 100755 scripts/generate-readme.sh create mode 100644 scripts/shell.nix diff --git a/.github/workflows/jsonnet-lint.yml b/.github/workflows/jsonnet-lint.yml index c123e96..3859934 100644 --- a/.github/workflows/jsonnet-lint.yml +++ b/.github/workflows/jsonnet-lint.yml @@ -21,10 +21,7 @@ jobs: with: fetch-depth: 0 - - name: Jsonnet formatter + - name: Jsonnet formatter and linter run: | - cd jsonnet && make --always-make fmt - - - name: Jsonnet linter - run: | - cd jsonnet && make --always-make lint + cd jsonnet && make --always-make all + diff --git a/deploy/charts/README.md b/deploy/charts/README.md index 60f017d..59fbc88 100644 --- a/deploy/charts/README.md +++ b/deploy/charts/README.md @@ -1,133 +1,115 @@ -# OpenEBS Monitoring - -[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) -![Chart Lint and Test](https://github.com/openebs/monitoring/workflows/Chart%20Lint%20and%20Test/badge.svg) -![Release Charts](https://github.com/openebs/monitoring/workflows/Release%20Charts/badge.svg?branch=develop) - -A Helm chart for OpenEBS monitoring. This chart bootstraps OpenEBS monitoring stack on a [Kubernetes](http://kubernetes.io) cluster using the -[Helm](https://helm.sh) package manager. - -**Homepage:** - -## Get Repo Info - -```console -helm repo add monitoring https://openebs.github.io/monitoring/ -helm repo update -``` - -_See [helm repo](https://helm.sh/docs/helm/helm_repo/) for command documentation._ - -## Install Chart - -Please visit the [link](https://openebs.github.io/monitoring/) for install instructions via helm3. - -```console -# Helm -helm install [RELEASE_NAME] monitoring/monitoring --namespace [NAMESPACE] --create-namespace -``` - -_See [configuration](#configuration) below._ - -_See [helm install](https://helm.sh/docs/helm/helm_install/) for command documentation._ - -## Dependencies - -By default this chart installs additional, dependent charts: - -| Repository | Name | Version | -| ------------------------------------------------------------------------------------------ | --------------------- | -------- | -| https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack | kube-prometheus-stack | `58.0.*` | -| https://charts.deliveryhero.io/ | node-problem-detector | `2.0.*` | - -_See [helm dependency](https://helm.sh/docs/helm/helm_dependency/) for command documentation._ - -## Uninstall Chart - -```console -# Helm -helm uninstall [RELEASE_NAME] --namespace [NAMESPACE] -``` - -This removes all the Kubernetes components associated with the chart and deletes the release. - -_See [helm uninstall](https://helm.sh/docs/helm/helm_uninstall/) for command documentation._ - -## Upgrading Chart - -```console -# Helm -helm upgrade [RELEASE_NAME] [CHART] --install --namespace [NAMESPACE] -``` - -## Configuration - -The following table lists the configurable parameters of the OpenEBS monitoring chart and their default values. - -You can modify different parameters by specifying the desired value in the `helm install` command by using the `--set` and/or the `--set-string` flag(s). You can modify the parameters of the [kube-prometheus-stack chart](https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack) by adding `kube-prometheus-stack` before the desired parameter in the `helm install` command. - -In the following sample command we modify `openebsMonitoringAddon.lvmLocalPV.enabled` from the monitoring chart and `kube-prometheus-stack.kubeProxy.enabled` from the kube-prometheus-stack chart to disable monitoring for lvmLocalPV and kube-proxy. - -```console -helm install monitoring monitoring/monitoring --namespace openebs --create-namespace \ - --set openebsMonitoringAddon.lvmLocalPV.enabled=false \ - --set kube-prometheus-stack.kubeProxy.enabled=false -``` - -| Parameter | Description | Default | -| ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | --------------------------------------------------------- | -| `kube-prometheus-stack.global.rbac.pspEnabled` | Disable PSP for alertmanager, prometheus and prometheus-operator | `false` | -| `kube-prometheus-stack.kube-state-metrics.podSecurityPolicy.enabled` | Disable PSP for kube-state-metrics | `false` | -| `kube-prometheus-stack.prometheus.service.type` | Service type for Prometheus | `"NodePort"` | -| `kube-prometheus-stack.prometheus.service.nodePort` | NodePort value for Prometheus service | `32514` | -| `kube-prometheus-stack.prometheus.prometheusSpec.serviceMonitorSelectorNilUsesHelmValues` | Enables Prometheus to select every service monitors | `false` | -| `kube-prometheus-stack.prometheus.prometheusSpec.podMonitorSelectorNilUsesHelmValues` | Enables Prometheus to select every pod monitors | `false` | -| `kube-prometheus-stack.prometheus.prometheusSpec.ruleSelectorNilUsesHelmValues` | Enables Prometheus to select every Prometheus rules | `false` | -| `kube-prometheus-stack.prometheus.prometheusSpec.replicas` | Number of instances to deploy for a Prometheus deployment | `1` | -| `kube-prometheus-stack.prometheus.prometheusSpec.storageSpec` | Storage spec to specify how storage shall be used. | `{}` | -| `kube-prometheus-stack.prometheus-node-exporter.rbac.pspEnabled` | Disable PSP for node-exporter | `false` | -| `kube-prometheus-stack.prometheus-node-exporter.securityContext` | Privilege and access control settings for node-exporter | `{...}` | -| `kube-prometheus-stack.prometheus-node-exporter.extraArgs` | Additional container arguments | `[...]` | -| `kube-prometheus-stack.alertmanager.enabled` | Deploy Alertmanager | `true` | -| `kube-prometheus-stack.alertmanager.config` | Provide YAML to configure Alertmanager. | `{...}` | -| `kube-prometheus-stack.alertmanager.service.type` | Service type for Alertmanager | `"NodePort"` | -| `kube-prometheus-stack.alertmanager.service.nodePort` | NodePort value for Alertmanager service | `30903` | -| `kube-prometheus-stack.alertmanager.alertmanagerSpec.replicas` | Number of instances to deploy for a Alertmanager deployment | `1` | -| `kube-prometheus-stack.alertmanager.alertmanagerSpec.storage` | Storage is the definition of how storage will be used by the Alertmanager instances | `{}` | -| `kube-prometheus-stack.prometheusOperator.enabled` | Deploy Prometheus Operator | `true` | -| `kube-prometheus-stack.grafana.enabled` | Enables monitoring of grafana itself | `true` | -| `kube-prometheus-stack.grafana.rbac.pspEnabled` | Disable PSP for grafana | `false` | -| `kube-prometheus-stack.grafana.grafana.ini` | Append to Grafana's primary configuration | `{panels: {disable_sanitize_html: true}}` | -| `kube-prometheus-stack.grafana.service.type` | Service type for Grafana | `"NodePort"` | -| `kube-prometheus-stack.grafana.service.nodePort` | NodePort value for Grafana service | `32515` | -| `kube-prometheus-stack.grafana.defaultDashboardsEnabled` | Deploys default dashboards | `true` | -| `kube-prometheus-stack.grafana.openebsDashboardsEnabled` | Deploys custom OpenEBS dashboards | `true` | -| `kube-prometheus-stack.grafana.adminPassword` | Administrator password for Grafana | `"admin"` | -| `kube-prometheus-stack.grafana.sidecar.dashboards.enabled` | Allows Grafana sidecar container to provision dashboards | `true` | -| `kube-prometheus-stack.grafana.sidecar.dashboards.label` | Labels for configmaps to be collected by Grafana sidecars | `"grafana_dashboard"` | -| `kube-prometheus-stack.grafana.plugins` | Adds Grafana plugin list to be installed | `["grafana-polystat-panel","snuids-trafficlights-panel"]` | -| `openebsMonitoringAddon.lvmLocalPV.enabled` | Enables installation of monitoring addons for lvm-LocalPV | `true` | -| `openebsMonitoringAddon.lvmLocalPV.dashboards.enabled` | Enables dashboard installation of OpenEBS lvm-localpv storage engine | `true` | -| `openebsMonitoringAddon.npd.dashboards.enabled` | Enables dashboard installation related to node problems | `true` | -| `node-problem-detector.extraVolumes` | Volumes needed by node problem detector | `[...]` | -| `node-problem-detector.extraVolumeMounts` | Volumes mounts needed by node problem detector | `[...]` | -| `node-problem-detector.metrics.serviceMonitor.enabled` | Enables node problem detector monitoring | `true` | -| `openebsMonitoringAddon.lvmLocalPV.alertRules.enabled` | Enables OpenEBS lvm-localpv Storage engine rules | `true` | -| `openebsMonitoringAddon.volume.alertRules.enabled` | Enables persistent volume rules | `true` | -| `openebsMonitoringAddon.lvmLocalPV.serviceMonitor.enabled` | Enables monitoring of lvm localPV | `true` | -| `openebsMonitoringAddon.lvmLocalPV.serviceMonitor.endpoints.port` | Name of the service port lvm localPV node endpoint refers to | `"metrics"` | -| `openebsMonitoringAddon.lvmLocalPV.serviceMonitor.endpoints.path` | HTTP path to scrape for metrics from lvm localPV node | `"/metrics"` | -| `openebsMonitoringAddon.lvmLocalPV.serviceMonitor.selector` | Selector to select endpoints objects | `{matchLabels: {name: openebs-lvm-node}}` | -| `openebsMonitoringAddon.lvmLocalPV.serviceMonitor.namespaceSelector` | Selector to select which namespaces the endpoints objects are discovered from | `[any: true]` | -| `openebsMonitoringAddon.zfsLocalPV.enabled` | Enables installation of monitoring addons for zfs LocalPV | `true` | -| `openebsMonitoringAddon.zfsLocalPV.dashboards.enabled` | Enables dashboard installation of OpenEBS zfs localPV Storage engine | `true` | - -We can edit the npd parameters too accordingly from [here](https://artifacthub.io/packages/helm/deliveryhero/node-problem-detector) - -A YAML file that specifies the values for the parameters can be provided while installing the chart. For example, - -```bash -helm install -f values.yaml --namespace monitoring monitoring/monitoring -``` - -> **Tip**: You can use the default [values.yaml](values.yaml) +# monitoring + +![Version: 4.0.1](https://img.shields.io/badge/Version-4.0.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 4.0.1](https://img.shields.io/badge/AppVersion-4.0.1-informational?style=flat-square) + +A Helm chart for monitoring OpenEBS + +## Source Code + +* + +## Requirements + +| Repository | Name | Version | +|------------|------|---------| +| https://charts.deliveryhero.io/ | node-problem-detector | 2.0.* | +| https://openebs.github.io/dynamic-localpv-provisioner | localpv-provisioner | 4.1.0 | +| https://prometheus-community.github.io/helm-charts | kube-prometheus-stack | 61.0.* | + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| fullnameOverride | string | `""` | | +| kube-prometheus-stack.alertmanager.alertmanagerSpec.replicas | int | `1` | | +| kube-prometheus-stack.alertmanager.alertmanagerSpec.storage | object | `{}` | | +| kube-prometheus-stack.alertmanager.config.global.resolve_timeout | string | `"5m"` | | +| kube-prometheus-stack.alertmanager.config.receivers[0].name | string | `"null"` | | +| kube-prometheus-stack.alertmanager.config.route.group_by[0] | string | `"alertname"` | | +| kube-prometheus-stack.alertmanager.config.route.group_by[1] | string | `"job"` | | +| kube-prometheus-stack.alertmanager.config.route.group_by[2] | string | `"volName"` | | +| kube-prometheus-stack.alertmanager.config.route.group_interval | string | `"5m"` | | +| kube-prometheus-stack.alertmanager.config.route.group_wait | string | `"30s"` | | +| kube-prometheus-stack.alertmanager.config.route.receiver | string | `"null"` | | +| kube-prometheus-stack.alertmanager.config.route.repeat_interval | string | `"4h"` | | +| kube-prometheus-stack.alertmanager.config.route.routes[0].matchers[0] | string | `"product=\"openebs\""` | | +| kube-prometheus-stack.alertmanager.config.route.routes[0].receiver | string | `"null"` | | +| kube-prometheus-stack.alertmanager.config.templates[0] | string | `"/etc/alertmanager/config/*.tmpl"` | | +| kube-prometheus-stack.alertmanager.enabled | bool | `true` | | +| kube-prometheus-stack.alertmanager.service.nodePort | int | `30903` | | +| kube-prometheus-stack.alertmanager.service.type | string | `"NodePort"` | | +| kube-prometheus-stack.global.rbac.pspEnabled | bool | `false` | | +| kube-prometheus-stack.grafana."grafana.ini".panels.disable_sanitize_html | bool | `true` | | +| kube-prometheus-stack.grafana.adminPassword | string | `"admin"` | | +| kube-prometheus-stack.grafana.defaultDashboardsEnabled | bool | `true` | | +| kube-prometheus-stack.grafana.enabled | bool | `true` | | +| kube-prometheus-stack.grafana.persistence.accessModes[0] | string | `"ReadWriteOnce"` | | +| kube-prometheus-stack.grafana.persistence.enabled | bool | `true` | | +| kube-prometheus-stack.grafana.persistence.size | string | `"1Gi"` | | +| kube-prometheus-stack.grafana.persistence.storageClassName | string | `"openebs-hostpath"` | | +| kube-prometheus-stack.grafana.plugins[0] | string | `"grafana-polystat-panel"` | | +| kube-prometheus-stack.grafana.plugins[1] | string | `"snuids-trafficlights-panel"` | | +| kube-prometheus-stack.grafana.rbac.pspEnabled | bool | `false` | | +| kube-prometheus-stack.grafana.service.nodePort | int | `32515` | | +| kube-prometheus-stack.grafana.service.type | string | `"NodePort"` | | +| kube-prometheus-stack.grafana.sidecar.dashboards.enabled | bool | `true` | | +| kube-prometheus-stack.grafana.sidecar.dashboards.label | string | `"grafana_dashboard"` | | +| kube-prometheus-stack.install | bool | `true` | | +| kube-prometheus-stack.kube-state-metrics.podSecurityPolicy.enabled | bool | `false` | | +| kube-prometheus-stack.prometheus-node-exporter.extraArgs[0] | string | `"--collector.filesystem.mount-points-exclude=^/(dev|proc|sys|var/lib/docker/.+)($|/)"` | | +| kube-prometheus-stack.prometheus-node-exporter.extraArgs[1] | string | `"--collector.filesystem.fs-types-exclude=^(tmpfs|autofs|binfmt_misc|cgroup|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|mqueue|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|sysfs|tracefs)$"` | | +| kube-prometheus-stack.prometheus-node-exporter.extraArgs[2] | string | `"--collector.diskstats.device-exclude=^(ram|loop|fd|sr|(h|s|v|xv)d[a-z]+|nvme\\d+n\\d+p|nvme\\d+c\\d+n)\\d+$"` | | +| kube-prometheus-stack.prometheus-node-exporter.rbac.pspEnabled | bool | `false` | | +| kube-prometheus-stack.prometheus-node-exporter.securityContext.fsGroup | int | `65534` | | +| kube-prometheus-stack.prometheus-node-exporter.securityContext.runAsGroup | int | `0` | | +| kube-prometheus-stack.prometheus-node-exporter.securityContext.runAsNonRoot | bool | `false` | | +| kube-prometheus-stack.prometheus-node-exporter.securityContext.runAsUser | int | `0` | | +| kube-prometheus-stack.prometheus.prometheusSpec.podMonitorSelectorNilUsesHelmValues | bool | `false` | | +| kube-prometheus-stack.prometheus.prometheusSpec.replicas | int | `1` | | +| kube-prometheus-stack.prometheus.prometheusSpec.ruleSelectorNilUsesHelmValues | bool | `false` | | +| kube-prometheus-stack.prometheus.prometheusSpec.serviceMonitorSelectorNilUsesHelmValues | bool | `false` | | +| kube-prometheus-stack.prometheus.prometheusSpec.storageSpec.volumeClaimTemplate.metadata.name | string | `"openebs-prometheus-pv"` | | +| kube-prometheus-stack.prometheus.prometheusSpec.storageSpec.volumeClaimTemplate.spec.accessModes[0] | string | `"ReadWriteOnce"` | | +| kube-prometheus-stack.prometheus.prometheusSpec.storageSpec.volumeClaimTemplate.spec.resources.requests.storage | string | `"1Gi"` | | +| kube-prometheus-stack.prometheus.prometheusSpec.storageSpec.volumeClaimTemplate.spec.storageClassName | string | `"openebs-hostpath"` | | +| kube-prometheus-stack.prometheus.service.nodePort | int | `32514` | | +| kube-prometheus-stack.prometheus.service.type | string | `"NodePort"` | | +| kube-prometheus-stack.prometheusOperator.enabled | bool | `true` | | +| localpv-provisioner.analytics.enabled | bool | `true` | | +| localpv-provisioner.enabled | bool | `true` | | +| localpv-provisioner.hostpathClass.enabled | bool | `true` | Enable default hostpath localpv StorageClass. | +| localpv-provisioner.hostpathClass.name | string | `"openebs-hostpath"` | | +| nameOverride | string | `""` | | +| namespaceOverride | string | `""` | | +| node-problem-detector.extraVolumeMounts[0].mountPath | string | `"/dev/kmsg"` | | +| node-problem-detector.extraVolumeMounts[0].name | string | `"kmsg"` | | +| node-problem-detector.extraVolumeMounts[0].readOnly | bool | `true` | | +| node-problem-detector.extraVolumes[0].hostPath.path | string | `"/dev/kmsg"` | | +| node-problem-detector.extraVolumes[0].name | string | `"kmsg"` | | +| node-problem-detector.install | bool | `false` | | +| node-problem-detector.metrics.serviceMonitor.enabled | bool | `true` | | +| openebsMonitoringAddon.lvmLocalPV.alertRules.enabled | bool | `true` | | +| openebsMonitoringAddon.lvmLocalPV.dashboards.enabled | bool | `true` | | +| openebsMonitoringAddon.lvmLocalPV.enabled | bool | `true` | | +| openebsMonitoringAddon.lvmLocalPV.serviceMonitor.enabled | bool | `true` | | +| openebsMonitoringAddon.lvmLocalPV.serviceMonitor.endpoints.path | string | `"/metrics"` | | +| openebsMonitoringAddon.lvmLocalPV.serviceMonitor.endpoints.port | string | `"metrics"` | | +| openebsMonitoringAddon.lvmLocalPV.serviceMonitor.namespaceSelector.any | bool | `true` | | +| openebsMonitoringAddon.lvmLocalPV.serviceMonitor.selector.matchLabels.name | string | `"openebs-lvm-node"` | | +| openebsMonitoringAddon.mayastor.dashboards.enabled | bool | `true` | | +| openebsMonitoringAddon.mayastor.enabled | bool | `true` | | +| openebsMonitoringAddon.mayastor.serviceMonitor.enabled | bool | `true` | | +| openebsMonitoringAddon.mayastor.serviceMonitor.endpoints.path | string | `"/metrics"` | | +| openebsMonitoringAddon.mayastor.serviceMonitor.endpoints.port | string | `"metrics"` | | +| openebsMonitoringAddon.mayastor.serviceMonitor.namespaceSelector.any | bool | `true` | | +| openebsMonitoringAddon.mayastor.serviceMonitor.selector.matchLabels.app | string | `"metrics-exporter-io-engine"` | | +| openebsMonitoringAddon.npd.alertRules.enabled | bool | `false` | | +| openebsMonitoringAddon.npd.dashboards.enabled | bool | `false` | | +| openebsMonitoringAddon.npd.enabled | bool | `false` | | +| openebsMonitoringAddon.volume.alertRules.enabled | bool | `true` | | +| openebsMonitoringAddon.volume.enabled | bool | `true` | | +| openebsMonitoringAddon.zfsLocalPV.dashboards.enabled | bool | `true` | | +| openebsMonitoringAddon.zfsLocalPV.enabled | bool | `true` | | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs vv1.11.0](https://github.com/norwoodj/helm-docs/releases/vv1.11.0) diff --git a/deploy/charts/templates/_helpers.tpl b/deploy/charts/templates/_helpers.tpl index 7f8c85c..78add3e 100644 --- a/deploy/charts/templates/_helpers.tpl +++ b/deploy/charts/templates/_helpers.tpl @@ -80,7 +80,7 @@ Usage: {{- range $subchart }} {{- $values = index $values . }} {{- end }} -{{- if $values.enabled }} # Add this condition to check if the subchart is enabled +{{- if $values.enabled }} {{- include $template (dict "Chart" (dict "Name" (last $subchart)) "Values" $values "Release" $dot.Release "Capabilities" $dot.Capabilities) }} {{- end }} {{- end }} diff --git a/jsonnet/Makefile b/jsonnet/Makefile index 2f42934..c74a5bc 100644 --- a/jsonnet/Makefile +++ b/jsonnet/Makefile @@ -2,39 +2,30 @@ SHELL=/usr/bin/env bash -o pipefail BIN_DIR?=$(shell pwd)/tmp/bin -EMBEDMD_BIN=$(BIN_DIR)/embedmd JB_BIN=$(BIN_DIR)/jb -GOJSONTOYAML_BIN=$(BIN_DIR)/gojsontoyaml JSONNET_BIN=$(BIN_DIR)/jsonnet JSONNETLINT_BIN=$(BIN_DIR)/jsonnet-lint JSONNETFMT_BIN=$(BIN_DIR)/jsonnetfmt -KUBECONFORM_BIN=$(BIN_DIR)/kubeconform -TOOLING=$(EMBEDMD_BIN) $(JB_BIN) $(GOJSONTOYAML_BIN) $(JSONNET_BIN) $(JSONNETLINT_BIN) $(JSONNETFMT_BIN) $(KUBECONFORM_BIN) +TOOLING=$(JB_BIN) $(JSONNET_BIN) $(JSONNETLINT_BIN) $(JSONNETFMT_BIN) JSONNETFMT_ARGS=-n 2 --max-blank-lines 2 --string-style s --comment-style s -KUBE_VERSION?="1.20.0" - -all: lint fmt generate +all: lint fmt .PHONY: clean clean: # Remove all files and directories ignored by git. git clean -Xfd . -vendor: $(JB_BIN) jsonnetfile.json jsonnetfile.lock.json - rm -rf vendor - $(JB_BIN) install - .PHONY: fmt fmt: $(JSONNETFMT_BIN) - find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \ + find . -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \ xargs -n 1 -- $(JSONNETFMT_BIN) $(JSONNETFMT_ARGS) -i .PHONY: lint -lint: $(JSONNETLINT_BIN) vendor - find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \ - xargs -n 1 -- $(JSONNETLINT_BIN) -J vendor +lint: $(JSONNETLINT_BIN) + find . -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \ + xargs -n 1 -- $(JSONNETLINT_BIN) $(BIN_DIR): diff --git a/jsonnet/buildscripts/go.mod b/jsonnet/buildscripts/go.mod index 2600c6e..162490f 100644 --- a/jsonnet/buildscripts/go.mod +++ b/jsonnet/buildscripts/go.mod @@ -3,23 +3,17 @@ module _ // go.mod created for tooling dependencies go 1.19 require ( - github.com/brancz/gojsontoyaml v0.1.0 - github.com/campoy/embedmd v1.0.0 github.com/google/go-jsonnet v0.20.0 github.com/jsonnet-bundler/jsonnet-bundler v0.4.0 - github.com/yannh/kubeconform v0.6.0 ) require ( github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect github.com/fatih/color v1.12.0 // indirect - github.com/ghodss/yaml v1.0.0 // indirect github.com/mattn/go-colorable v0.1.8 // indirect github.com/mattn/go-isatty v0.0.12 // indirect github.com/pkg/errors v0.8.0 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/santhosh-tekuri/jsonschema/v5 v5.1.1 // indirect golang.org/x/sys v0.1.0 // indirect gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/jsonnet/buildscripts/go.sum b/jsonnet/buildscripts/go.sum index dd4ddb4..bde0ec4 100644 --- a/jsonnet/buildscripts/go.sum +++ b/jsonnet/buildscripts/go.sum @@ -2,9 +2,6 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5Vpd github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/brancz/gojsontoyaml v0.1.0 h1:SdzR3+BCVOqaI42nFGTeaB7/2DgDM4fhuvRLqxatA8M= -github.com/brancz/gojsontoyaml v0.1.0/go.mod h1:+ycZY94+V11XZBUaDEsbLr3hPNS/ZPrDVKKNUg3Sgvg= -github.com/campoy/embedmd v1.0.0 h1:V4kI2qTJJLf4J29RzI/MAt2c3Bl4dQSYPuflzwFH2hY= github.com/campoy/embedmd v1.0.0/go.mod h1:oxyr9RCiSXg0M3VJ3ks0UGfp98BpSSGr0kpiX3MzVl8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -12,8 +9,6 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.12.0 h1:mRhaKNwANqRgUBGKmnI5ZxEk7QXmjQeCcuYFMX2bfcc= github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= -github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/google/go-jsonnet v0.20.0 h1:WG4TTSARuV7bSm4PMB4ohjxe33IHT5WVTrJSU33uT4g= github.com/google/go-jsonnet v0.20.0/go.mod h1:VbgWF9JX7ztlv770x/TolZNGGFfiHEVx9G6ca2eUmeA= github.com/jsonnet-bundler/jsonnet-bundler v0.4.0 h1:4BKZ6LDqPc2wJDmaKnmYD/vDjUptJtnUpai802MibFc= @@ -28,14 +23,10 @@ github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/santhosh-tekuri/jsonschema/v5 v5.1.1 h1:lEOLY2vyGIqKWUI9nzsOJRV3mb3WC9dXYORsLEUcoeY= -github.com/santhosh-tekuri/jsonschema/v5 v5.1.1/go.mod h1:FKdcjfQW6rpZSnxxUvEA5H/cDPdvJ/SZJQLWWXWGrZ0= github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/yannh/kubeconform v0.6.0 h1:4Figo6t2OF8yNkC+cqa8qy20jcYY0LsJF0+p2klZZiU= -github.com/yannh/kubeconform v0.6.0/go.mod h1:4E6oaL+lh7KgCG2SaOabeeAFBkyKu5D9ab0OEekGcbs= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190310054646-10058d7d4faa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/jsonnet/buildscripts/tools.go b/jsonnet/buildscripts/tools.go index 288ad57..0cbbf87 100644 --- a/jsonnet/buildscripts/tools.go +++ b/jsonnet/buildscripts/tools.go @@ -5,11 +5,8 @@ package tools import ( - _ "github.com/brancz/gojsontoyaml" - _ "github.com/campoy/embedmd" _ "github.com/google/go-jsonnet/cmd/jsonnet" _ "github.com/google/go-jsonnet/cmd/jsonnet-lint" _ "github.com/google/go-jsonnet/cmd/jsonnetfmt" _ "github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb" - _ "github.com/yannh/kubeconform/cmd/kubeconform" ) diff --git a/jsonnet/jsonnetfile.json b/jsonnet/jsonnetfile.json deleted file mode 100644 index 22689f4..0000000 --- a/jsonnet/jsonnetfile.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "version": 1, - "dependencies": [ - { - "source": { - "git": { - "remote": "https://github.com/prometheus-operator/kube-prometheus.git", - "subdir": "jsonnet/kube-prometheus" - } - }, - "version": "61.0.0" - } - ], - "legacyImports": true -} diff --git a/jsonnet/jsonnetfile.lock.json b/jsonnet/jsonnetfile.lock.json deleted file mode 100644 index 77e4e95..0000000 --- a/jsonnet/jsonnetfile.lock.json +++ /dev/null @@ -1,171 +0,0 @@ -{ - "version": 1, - "dependencies": [ - { - "source": { - "git": { - "remote": "https://github.com/brancz/kubernetes-grafana.git", - "subdir": "grafana" - } - }, - "version": "8ea4e7bc04b1bf5e9bd99918ca28c6271b42be0e", - "sum": "muenICtKXABk6MZZHCZD2wCbmtiE96GwWRMGa1Rg+wA=" - }, - { - "source": { - "git": { - "remote": "https://github.com/etcd-io/etcd.git", - "subdir": "contrib/mixin" - } - }, - "version": "562d645ac923388ff5b8d270b0536764d34b0e0f", - "sum": "W/Azptf1PoqjyMwJON96UY69MFugDA4IAYiKURscryc=" - }, - { - "source": { - "git": { - "remote": "https://github.com/grafana/grafonnet-lib.git", - "subdir": "grafonnet" - } - }, - "version": "3082bfca110166cd69533fa3c0875fdb1b68c329", - "sum": "4/sUV0Kk+o8I+wlYxL9R6EPhL/NiLfYHk+NXlU64RUk=" - }, - { - "source": { - "git": { - "remote": "https://github.com/grafana/jsonnet-libs.git", - "subdir": "grafana-builder" - } - }, - "version": "81696e4d5fda54c25b7129eadade2976e3f19dc5", - "sum": "GRf2GvwEU4jhXV+JOonXSZ4wdDv8mnHBPCQ6TUVd+g8=" - }, - { - "source": { - "git": { - "remote": "https://github.com/ksonnet/ksonnet-lib.git", - "subdir": "" - } - }, - "version": "0d2f82676817bbf9e4acf6495b2090205f323b9f", - "sum": "h28BXZ7+vczxYJ2sCt8JuR9+yznRtU/iA6DCpQUrtEg=", - "name": "ksonnet" - }, - { - "source": { - "git": { - "remote": "https://github.com/kubernetes-monitoring/kubernetes-mixin.git", - "subdir": "" - } - }, - "version": "e15ab56a4eea721d1e958888fd13c4b95af4d17d", - "sum": "voj/Pfit89sI+xBCyFV8oEV4UgnsaJZ2VrOU7s9jZe8=" - }, - { - "source": { - "git": { - "remote": "https://github.com/kubernetes-monitoring/kubernetes-mixin.git", - "subdir": "lib/promgrafonnet" - } - }, - "version": "b710a868a95621aa93e0b661954f63f4db82aaea", - "sum": "zv7hXGui6BfHzE9wPatHI/AGZa4A2WKo6pq7ZdqBsps=" - }, - { - "source": { - "git": { - "remote": "https://github.com/kubernetes/kube-state-metrics.git", - "subdir": "jsonnet/kube-state-metrics" - } - }, - "version": "b1889aa1561ee269f628e2b9659155e7714dbbf0", - "sum": "S5qI+PJUdNeYOv76jH5nxwYS9N6U7CRxvyuB1wI4cTE=" - }, - { - "source": { - "git": { - "remote": "https://github.com/kubernetes/kube-state-metrics.git", - "subdir": "jsonnet/kube-state-metrics-mixin" - } - }, - "version": "b1889aa1561ee269f628e2b9659155e7714dbbf0", - "sum": "Yf8mNAHrV1YWzrdV8Ry5dJ8YblepTGw3C0Zp10XIYLo=" - }, - { - "source": { - "git": { - "remote": "https://github.com/prometheus-operator/kube-prometheus.git", - "subdir": "jsonnet/kube-prometheus" - } - }, - "version": "e8b58191b586d23c3a19bbf045c78630b568b29b", - "sum": "e/4y/phKZ+cCDPCW6WAwSaO9kJk1TyyDwcR+/f9qkrQ=" - }, - { - "source": { - "git": { - "remote": "https://github.com/prometheus-operator/prometheus-operator.git", - "subdir": "jsonnet/mixin" - } - }, - "version": "b7ca32169844f0b5143f3e5e318fc05fa025df18", - "sum": "6reUygVmQrLEWQzTKcH8ceDbvM+2ztK3z2VBR2K2l+U=", - "name": "prometheus-operator-mixin" - }, - { - "source": { - "git": { - "remote": "https://github.com/prometheus-operator/prometheus-operator.git", - "subdir": "jsonnet/prometheus-operator" - } - }, - "version": "b7ca32169844f0b5143f3e5e318fc05fa025df18", - "sum": "MRwyChXdKG3anL2OWpbUu3qWc97w9J6YsjUWjLFQyB0=" - }, - { - "source": { - "git": { - "remote": "https://github.com/prometheus/alertmanager.git", - "subdir": "doc/alertmanager-mixin" - } - }, - "version": "99f64e944b1043c790784cf5373c8fb349816fc4", - "sum": "V8jcZQ1Qrlm7AQ6wjbuQQsacPb0NvrcZovKyplmzW5w=", - "name": "alertmanager" - }, - { - "source": { - "git": { - "remote": "https://github.com/prometheus/node_exporter.git", - "subdir": "docs/node-mixin" - } - }, - "version": "b597c1244d7bef49e6f3359c87a56dd7707f6719", - "sum": "cZTNXQMUCLB5FGYpMn845dcqGdkcYt58qCqOFIV/BoQ=" - }, - { - "source": { - "git": { - "remote": "https://github.com/prometheus/prometheus.git", - "subdir": "documentation/prometheus-mixin" - } - }, - "version": "6eeded0fdf760e81af75d9c44ce539ab77da4505", - "sum": "VK0c3sQ3ksiM6JQsAVfWmL5NbzGv9llMfXFNXfFdJ+A=", - "name": "prometheus" - }, - { - "source": { - "git": { - "remote": "https://github.com/thanos-io/thanos.git", - "subdir": "mixin" - } - }, - "version": "ba6c5c4726ff52807c7383c68f2159b1af7980bb", - "sum": "XP3uq7xcfKHsnWsz1v992csZhhZR3jQma6hFOfSViTs=", - "name": "thanos-mixin" - } - ], - "legacyImports": false -} diff --git a/nix/README.md b/nix/README.md new file mode 100644 index 0000000..16c309e --- /dev/null +++ b/nix/README.md @@ -0,0 +1,14 @@ +## Overview + +These are a collection of packages we need, or packages where we +want to control the exact version(s) of. + +The packages are imported through the `nix-shell` automatically. + +## nix-shell + +Build environment including all test and debug dependencies. +It can be run with two arguments: + +* `--arg norust true`: to use your own rust toolchain. +* `--arg devrustup true`: to use rustup. diff --git a/nix/lib/rust.nix b/nix/lib/rust.nix new file mode 100644 index 0000000..53bc49f --- /dev/null +++ b/nix/lib/rust.nix @@ -0,0 +1,31 @@ +{ sources ? import ../sources.nix }: +let + pkgs = + import sources.nixpkgs { overlays = [ (import sources.rust-overlay) ]; }; + makeRustTarget = platform: pkgs.rust.toRustTargetSpec platform; + static_target = makeRustTarget pkgs.pkgsStatic.stdenv.hostPlatform; +in +rec { + inherit makeRustTarget; + rust_default = { override ? { } }: rec { + nightly_pkg = pkgs.rust-bin.nightly."2023-10-05"; + stable_pkg = pkgs.rust-bin.stable."1.72.1"; + + nightly = nightly_pkg.default.override (override); + stable = stable_pkg.default.override (override); + + nightly_src = nightly_pkg.rust-src; + release_src = stable_pkg.rust-src; + }; + default = rust_default { }; + default_src = rust_default { + override = { extensions = [ "rust-src" ]; }; + }; + static = { target ? makeRustTarget pkgs.pkgsStatic.stdenv.hostPlatform }: rust_default { + override = { targets = [ "${target}" ]; }; + }; + hostStatic = rust_default { override = { targets = [ "${makeRustTarget pkgs.pkgsStatic.stdenv.hostPlatform}" ]; }; }; + windows_cross = rust_default { + override = { targets = [ "${pkgs.rust.toRustTargetSpec pkgs.pkgsCross.mingwW64.hostPlatform}" ]; }; + }; +} diff --git a/nix/lib/sourcer.nix b/nix/lib/sourcer.nix new file mode 100644 index 0000000..d3d80d5 --- /dev/null +++ b/nix/lib/sourcer.nix @@ -0,0 +1,24 @@ +{ lib, stdenv, git, sourcer, tag ? "" }: +let + whitelistSource = src: allowedPrefixes: + builtins.path { + filter = (path: type: + (lib.any + (allowedPrefix: + (lib.hasPrefix (toString (src + "/${allowedPrefix}")) path) || + (type == "directory" && lib.hasPrefix path (toString (src + "/${allowedPrefix}"))) + ) + allowedPrefixes) + ## Remove unwanted files, example: + # && path != (toString (src + "/utils/dependencies/scripts/release.sh")) + ); + path = src; + name = "puls8"; + }; +in +{ + inherit whitelistSource; + + git-src = whitelistSource ../../. [ ".git" ]; + repo-org = whitelistSource ../../mayastor-extensions/dependencies/control-plane/utils/dependencies/scripts [ "git-org-name.sh" ]; +} diff --git a/nix/overlay.nix b/nix/overlay.nix new file mode 100644 index 0000000..0ed5810 --- /dev/null +++ b/nix/overlay.nix @@ -0,0 +1,4 @@ +{}: +self: super: { + sourcer = super.callPackage ./lib/sourcer.nix { }; +} diff --git a/nix/sources.json b/nix/sources.json new file mode 100644 index 0000000..d0c3385 --- /dev/null +++ b/nix/sources.json @@ -0,0 +1,50 @@ +{ + "naersk": { + "branch": "master", + "description": "Build rust crates in Nix. No configuration, no code generation, no IFD. Sandbox friendly. [maintainer: @nmattia]", + "homepage": "", + "owner": "nix-community", + "repo": "naersk", + "rev": "d9a33d69a9c421d64c8d925428864e93be895dcc", + "sha256": "1lhz5haibfnbxwir61mhymxfqfgs2q1nb4rk88va8bpv6j2zlpbv", + "type": "tarball", + "url": "https://github.com/nix-community/naersk/archive/d9a33d69a9c421d64c8d925428864e93be895dcc.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "niv": { + "branch": "master", + "description": "Easy dependency management for Nix projects", + "homepage": "https://github.com/nmattia/niv", + "owner": "nmattia", + "repo": "niv", + "rev": "914aba08a26cb10538b84d00d6cfb01c9776d80c", + "sha256": "0gx316gc7prjay5b0cr13x4zc2pdbiwxkfkpjvrlb2rml80lm4pm", + "type": "tarball", + "url": "https://github.com/nmattia/niv/archive/914aba08a26cb10538b84d00d6cfb01c9776d80c.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "nixpkgs": { + "branch": "release-22.11", + "description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to", + "homepage": "https://github.com/NixOS/nixpkgs", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b", + "sha256": "1xi53rlslcprybsvrmipm69ypd3g3hr7wkxvzc73ag8296yclyll", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, + "rust-overlay": { + "branch": "master", + "description": "Pure and reproducible nix overlay for binary distributed rust toolchains", + "homepage": "", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "c0df7f2a856b5ff27a3ce314f6d7aacf5fda546f", + "sha256": "0hm2yznc083bys92h6zrx5lsar5nqphx1h27p7pxz4x7hmilxpsy", + "type": "tarball", + "url": "https://github.com/oxalica/rust-overlay/archive/c0df7f2a856b5ff27a3ce314f6d7aacf5fda546f.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + } +} diff --git a/nix/sources.nix b/nix/sources.nix new file mode 100644 index 0000000..8f50fc8 --- /dev/null +++ b/nix/sources.nix @@ -0,0 +1,144 @@ +# This file has been generated by Niv. +let + # + # The fetchers. fetch_ fetches specs of type . + # + + fetch_file = pkgs: spec: + if spec.builtin or true then + builtins_fetchurl { inherit (spec) url sha256; } + else + pkgs.fetchurl { inherit (spec) url sha256; }; + + fetch_tarball = pkgs: spec: + if spec.builtin or true then + builtins_fetchTarball { inherit (spec) url sha256; } + else + pkgs.fetchzip { inherit (spec) url sha256; }; + + fetch_git = spec: + builtins.fetchGit { + url = spec.repo; + inherit (spec) rev ref; + }; + + fetch_builtin-tarball = spec: + builtins.trace '' + WARNING: + The niv type "builtin-tarball" will soon be deprecated. You should + instead use `builtin = true`. + + $ niv modify -a type=tarball -a builtin=true + '' + builtins_fetchTarball + { inherit (spec) url sha256; }; + + fetch_builtin-url = spec: + builtins.trace '' + WARNING: + The niv type "builtin-url" will soon be deprecated. You should + instead use `builtin = true`. + + $ niv modify -a type=file -a builtin=true + '' + (builtins_fetchurl { inherit (spec) url sha256; }); + + # + # Various helpers + # + + # The set of packages used when specs are fetched using non-builtins. + mkPkgs = sources: + let + sourcesNixpkgs = + import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) + { }; + hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; + hasThisAsNixpkgsPath = == ./.; + in + if builtins.hasAttr "nixpkgs" sources then + sourcesNixpkgs + else if hasNixpkgsPath && !hasThisAsNixpkgsPath then + import { } + else + abort '' + Please specify either (through -I or NIX_PATH=nixpkgs=...) or + add a package called "nixpkgs" to your sources.json. + ''; + + # The actual fetching function. + fetch = pkgs: name: spec: + + if !builtins.hasAttr "type" spec then + abort "ERROR: niv spec ${name} does not have a 'type' attribute" + else if spec.type == "file" then + fetch_file pkgs spec + else if spec.type == "tarball" then + fetch_tarball pkgs spec + else if spec.type == "git" then + fetch_git spec + else if spec.type == "builtin-tarball" then + fetch_builtin-tarball spec + else if spec.type == "builtin-url" then + fetch_builtin-url spec + else + abort + "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; + + # Ports of functions for older nix versions + + # a Nix version of mapAttrs if the built-in doesn't exist + mapAttrs = builtins.mapAttrs or (f: set: + with builtins; + listToAttrs (map + (attr: { + name = attr; + value = f attr set.${attr}; + }) + (attrNames set))); + + # fetchTarball version that is compatible between all the versions of Nix + builtins_fetchTarball = { url, sha256 }@attrs: + let inherit (builtins) lessThan nixVersion fetchTarball; + in + if lessThan nixVersion "1.12" then + fetchTarball { inherit url; } + else + fetchTarball attrs; + + # fetchurl version that is compatible between all the versions of Nix + builtins_fetchurl = { url, sha256 }@attrs: + let inherit (builtins) lessThan nixVersion fetchurl; + in + if lessThan nixVersion "1.12" then + fetchurl { inherit url; } + else + fetchurl attrs; + + # Create the final "sources" from the config + mkSources = config: + mapAttrs + (name: spec: + if builtins.hasAttr "outPath" spec then + abort + "The values in sources.json should not have an 'outPath' attribute" + else + spec // { outPath = fetch config.pkgs name spec; }) + config.sources; + + # The "config" used by the fetchers + mkConfig = + { sourcesFile ? ./sources.json + , sources ? builtins.fromJSON (builtins.readFile sourcesFile) + , pkgs ? mkPkgs sources + }: rec { + # The sources, i.e. the attribute set of spec name to spec + inherit sources; + + # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers + inherit pkgs; + }; +in +mkSources (mkConfig { }) // { + __functor = _: settings: mkSources (mkConfig settings); +} diff --git a/scripts/generate-readme.sh b/scripts/generate-readme.sh new file mode 100755 index 0000000..65cbb43 --- /dev/null +++ b/scripts/generate-readme.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +SCRIPTDIR=$(dirname "$0") +ROOTDIR="$(realpath $SCRIPTDIR/..)" +CHART_DIR="$ROOTDIR/deploy/charts" +README="README.md" +SKIP_GIT=${SKIP_GIT:-} + +set -euo pipefail + +helm-docs -c "$ROOTDIR" -g "$CHART_DIR" -o $README + + +if [ -z "$SKIP_GIT" ]; then + git diff --exit-code "$CHART_DIR/$README" +fi diff --git a/scripts/shell.nix b/scripts/shell.nix new file mode 100644 index 0000000..bc228e1 --- /dev/null +++ b/scripts/shell.nix @@ -0,0 +1,21 @@ +{}: +let + sources = import ../nix/sources.nix; + pkgs = import sources.nixpkgs { + overlays = [ (_: _: { inherit sources; }) (import ../nix/overlay.nix { }) ]; + }; +in +with pkgs; +let +in +mkShell { + name = "helm-scripts-shell"; + buildInputs = [ + coreutils + git + helm-docs + kubernetes-helm-wrapped + semver-tool + yq-go + ]; +}