diff --git a/.goreleaser.yml b/.goreleaser.yml index f107cac..9c25113 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,6 +1,8 @@ builds: - main: main.go binary: helm3-monitor + env: + - CGO_ENABLED=0 goos: - darwin - linux diff --git a/README.md b/README.md index 55561da..3c4bd56 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,21 @@ -# helm3-monitor -Monitor K8S Helm3 release, rollback on Prometheus query +# Helm3 Monitor Plugin +Monitor a Helm3 release, rollback to a previous version depending on the result of a PromQL (Prometheus) query result + +## Install + +```shell +> helm plugin install https://github.com/yq314/helm3-monitor +``` + +## Usage + +A rollback happen only if the number of result from the query is greater than 0. + +You can find a step-by-step example in the ./examples directory. + +```shell +> helm monitor prometheus --prometheus=http://prometheus:9090 \ + \ + 'rate(http_requests_total{statusClass!="2XX"}[5m]) / rate(http_requests_total[5m]) > 0.01' +``` diff --git a/examples/README.md b/examples/README.md index 3e54396..3086240 100644 --- a/examples/README.md +++ b/examples/README.md @@ -14,7 +14,7 @@ Install Prometheus helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm repo add kube-state-metrics https://kubernetes.github.io/kube-state-metrics helm repo update -helm --namespace prometheus install -f ./prometheus.yml --create-namespace prometheus prometheus-community/prometheus +helm --namespace prometheus upgrade -i -f ./prometheus.yml --create-namespace prometheus prometheus-community/prometheus ``` Install Infrabin diff --git a/scripts/install_plugin.sh b/scripts/install_plugin.sh index e9c04c0..21e198b 100755 --- a/scripts/install_plugin.sh +++ b/scripts/install_plugin.sh @@ -27,15 +27,15 @@ fi echo "$url" -#mkdir -p "bin" -#mkdir -p "releases/v${version}" -# -#if [ -x "$(which curl 2>/dev/null)" ]; then -# curl -sSL "${url}" -o "releases/v${version}.tar.gz" -#else -# wget -q "${url}" -O "releases/v${version}.tar.gz" -#fi -#tar xzf "releases/v${version}.tar.gz" -C "releases/v${version}" +mkdir -p "bin" +mkdir -p "releases/v${version}" + +if [ -x "$(which curl 2>/dev/null)" ]; then + curl -sSL "${url}" -o "releases/v${version}.tar.gz" +else + wget -q "${url}" -O "releases/v${version}.tar.gz" +fi +tar xzf "releases/v${version}.tar.gz" -C "releases/v${version}" mv "releases/v${version}/helm3-monitor" "bin/helm3-monitor" || \ mv "releases/v${version}/helm3-monitor.exe" "bin/helm3-monitor" mv "releases/v${version}/completion.yaml" .