-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add support for rendering an optional PrometheusOperator ServiceMonitor resource definition #271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: add support for rendering an optional PrometheusOperator ServiceMonitor resource definition #271
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
029df12
feat: add helper scripts to manage prometheus deployment
leninmehedy 07fe722
fix: use network-node-svc label selector
leninmehedy cc4eac2
fix: install prometheus operator only if crds are not installed yet
leninmehedy 36c9145
feat: deploy prometheus service monitor conditionally along with hede…
leninmehedy a59ab4b
style: add missing new lines
leninmehedy 3fa482d
fix: allow prometheus service monitor endpoints to be set by user
leninmehedy 29a7b8a
Merge branch 'main' into 227-prometheus-servicemonitor
leninmehedy 77e427d
ci: setup prometheus operator in CI/CD pipeline
leninmehedy 4a68fa2
fix: update dev script to deploy prometheus operator locally if not i…
leninmehedy 3664f81
style: fix spotless lint issue
leninmehedy cfcd596
fix: function definition in bash script for consistency
leninmehedy ee18328
Merge branch 'main' into 227-prometheus-servicemonitor
leninmehedy 54e5cb3
Update charts/hedera-network/templates/services/network-node-svc.yaml
leninmehedy f5d5fc9
fix: remove otel ports from value file
leninmehedy e68165a
Merge branch 'main' into 227-prometheus-servicemonitor
leninmehedy 9cb82c2
fix: port name and updated README for manual tests
leninmehedy 59248e6
fix: port name
leninmehedy bff50ba
fix: install minio operator if not installed already during network d…
leninmehedy 00d9b9c
fix: increase timeout during example app deployment
leninmehedy 2072ad3
fix: only expose OTel metrics port from node svc
leninmehedy 5e57f43
fix: update health-check port name for otel collector
leninmehedy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
charts/hedera-network/templates/telemetry/prometheus-svc-monitor.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| {{- if $.Values.telemetry.prometheus.svcMonitor.enable | eq "true" }} | ||
| apiVersion: monitoring.coreos.com/v1 | ||
| kind: ServiceMonitor | ||
| metadata: | ||
| name: network-node-monitor | ||
| labels: | ||
| fullstack.hedera.com/type: network-node-svc-monitor | ||
| spec: | ||
| selector: | ||
| matchLabels: | ||
| fullstack.hedera.com/type: network-node-svc | ||
| endpoints: | ||
| - port: otel-metrics | ||
| interval: 5s | ||
| {{- end }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" | ||
| readonly SCRIPT_DIR | ||
| readonly TELEMETRY_DIR="${SCRIPT_DIR}/../telemetry" | ||
| readonly PROMETHEUS_DIR="${TELEMETRY_DIR}/prometheus" | ||
|
|
||
| # Run the below command to retrieve the latest version | ||
| # curl -s "https://api.github.com/repos/prometheus-operator/prometheus-operator/releases/latest" | jq -cr .tag_name | ||
| readonly PROMETHEUS_VERSION=v0.67.1 | ||
| readonly PROMETHEUS_OPERATOR_YAML="${PROMETHEUS_DIR}/prometheus-operator.yaml" | ||
| readonly PROMETHEUS_YAML="${PROMETHEUS_DIR}/prometheus.yaml" | ||
| readonly PROMETHEUS_RBAC_YAML="${PROMETHEUS_DIR}/prometheus-rbac.yaml" | ||
| readonly PROMETHEUS_EXAMPLE_APP_YAML="${PROMETHEUS_DIR}/example-app.yaml" | ||
|
|
||
| function fetch-prometheus-operator-bundle() { | ||
| if [[ ! -f "${PROMETHEUS_OPERATOR_YAML}" ]]; then \ | ||
| echo "" | ||
| echo "Fetching prometheus bundle: https://github.com/prometheus-operator/prometheus-operator/releases/download/${PROMETHEUS_VERSION}/bundle.yaml" | ||
| echo "PROMETHEUS_OPERATOR_YAML: ${PROMETHEUS_OPERATOR_YAML}" | ||
| echo "-----------------------------------------------------------------------------------------------------" | ||
| echo "Fetching prometheus bundle: https://github.com/prometheus-operator/prometheus-operator/releases/download/${PROMETHEUS_VERSION}/bundle.yaml > ${PROMETHEUS_OPERATOR_YAML}" | ||
| curl -sL --fail-with-body "https://github.com/prometheus-operator/prometheus-operator/releases/download/${PROMETHEUS_VERSION}/bundle.yaml" -o "${PROMETHEUS_OPERATOR_YAML}" | ||
| local status="$?" | ||
| [[ "${status}" != 0 ]] && rm "${PROMETHEUS_OPERATOR_YAML}" && echo "ERROR: Failed to fetch prometheus bundle" | ||
| return "${status}" | ||
| fi | ||
| } | ||
|
|
||
| function deploy-prometheus-operator() { | ||
| echo "" | ||
| echo "Deploying prometheus operator" | ||
| echo "PROMETHEUS_OPERATOR_YAML: ${PROMETHEUS_OPERATOR_YAML}" | ||
| echo "-----------------------------------------------------------------------------------------------------" | ||
| local crd_count=$(kubectl get crd | grep "monitoring.coreos.com" | wc -l) | ||
| if [[ $crd_count -ne 10 ]]; then | ||
| kubectl create -f "${PROMETHEUS_OPERATOR_YAML}" | ||
| kubectl wait --for=condition=Ready pods -l app.kubernetes.io/name=prometheus-operator -n default | ||
| else | ||
| echo "Kubernetes operator CRD is already installed" | ||
| fi | ||
| } | ||
|
|
||
| function destroy-prometheus-operator() { | ||
| echo "" | ||
| echo "Destroying prometheus operator" | ||
| echo "PROMETHEUS_OPERATOR_YAML: ${PROMETHEUS_OPERATOR_YAML}" | ||
| echo "-----------------------------------------------------------------------------------------------------" | ||
| kubectl delete -f "${PROMETHEUS_OPERATOR_YAML}" | ||
| sleep 10 | ||
| } | ||
|
|
||
| function deploy-prometheus() { | ||
| echo "" | ||
| echo "Deploying prometheus" | ||
| echo "PROMETHEUS_RBAC_YAML: ${PROMETHEUS_RBAC_YAML}" | ||
| echo "PROMETHEUS_YAML: ${PROMETHEUS_YAML}" | ||
| echo "-----------------------------------------------------------------------------------------------------" | ||
| kubectl create -f "${PROMETHEUS_RBAC_YAML}" | ||
| sleep 10 | ||
| kubectl create -f "${PROMETHEUS_YAML}" | ||
| echo "Waiting for prometheus to be running..." | ||
| kubectl wait --for=condition=Ready pods -l app.kubernetes.io/name=prometheus -n default --timeout 300s | ||
| } | ||
|
|
||
| function destroy-prometheus() { | ||
| echo "" | ||
| echo "Destroying prometheus" | ||
| echo "PROMETHEUS_RBAC_YAML: ${PROMETHEUS_RBAC_YAML}" | ||
| echo "PROMETHEUS_YAML: ${PROMETHEUS_YAML}" | ||
| echo "-----------------------------------------------------------------------------------------------------" | ||
| kubectl delete -f "${PROMETHEUS_YAML}" | ||
| kubectl delete -f "${PROMETHEUS_RBAC_YAML}" | ||
| sleep 5 | ||
| } | ||
|
|
||
| function deploy-prometheus-example-app() { | ||
| echo "" | ||
| echo "Deploying prometheus-example-app" | ||
| echo "PROMETHEUS_EXAMPLE_APP_YAML: ${PROMETHEUS_EXAMPLE_APP_YAML}" | ||
| echo "-----------------------------------------------------------------------------------------------------" | ||
| kubectl create -f "${PROMETHEUS_EXAMPLE_APP_YAML}" | ||
| kubectl wait --for=condition=Ready pods -l app=prometheus-example-app -n default --timeout 60 | ||
| } | ||
|
|
||
| function destroy-prometheus-example-app() { | ||
| echo "" | ||
| echo "Destroying prometheus-example-app" | ||
| echo "PROMETHEUS_EXAMPLE_APP_YAML: ${PROMETHEUS_EXAMPLE_APP_YAML}" | ||
| echo "-----------------------------------------------------------------------------------------------------" | ||
| kubectl delete -f "${PROMETHEUS_EXAMPLE_APP_YAML}" | ||
| local status="$?" | ||
| [[ "${status}" = 0 ]] && sleep 10 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # Force the use of bash as the shell for more features | ||
| SHELL=/bin/bash | ||
|
|
||
| # Ensure we can catch error to run cleanup when multiple make commands are run in sequence. | ||
| # Here we tell make to run all scripts as one-shell and also set 'pipefail' and 'errexit' flags. | ||
| # https://stackoverflow.com/questions/28597794/how-can-i-clean-up-after-an-error-in-a-makefile | ||
| SHELLOPTS:=$(if $(SHELLOPTS),$(SHELLOPTS):)pipefail:errexit | ||
| .ONESHELL: | ||
|
|
||
| # Run the below command to retrieve the latest version | ||
| # curl -s "https://api.github.com/repos/prometheus-operator/prometheus-operator/releases/latest" | jq -cr .tag_name | ||
| PROMETHEUS_VERSION=v0.67.1 | ||
|
|
||
| SCRIPTS_DIR=$(PWD)/../../scripts | ||
| TELEMETRY_SCRIPT="telemetry.sh" | ||
|
|
||
| .SILENT: fetch-operator-bundle | ||
|
|
||
| .PHONY: fetch-operator-bundle | ||
| fetch-operator-bundle: | ||
| source "${SCRIPTS_DIR}/${TELEMETRY_SCRIPT}" && fetch-prometheus-operator-bundle | ||
|
|
||
|
|
||
| .PHONY: deploy-prometheus-operator | ||
| deploy-prometheus-operator: fetch-operator-bundle | ||
| source "${SCRIPTS_DIR}/${TELEMETRY_SCRIPT}" && deploy-prometheus-operator | ||
|
|
||
| .PHONY: destroy-prometheus-operator | ||
| destroy-prometheus-operator: | ||
| source "${SCRIPTS_DIR}/${TELEMETRY_SCRIPT}" && destroy-prometheus-operator | ||
|
|
||
| .PHONY: deploy-prometheus | ||
| deploy-prometheus: deploy-prometheus-operator | ||
| source "${SCRIPTS_DIR}/${TELEMETRY_SCRIPT}" && deploy-prometheus | ||
|
|
||
| .PHONY: destroy-prometheus | ||
| destroy-prometheus: | ||
| source "${SCRIPTS_DIR}/${TELEMETRY_SCRIPT}" && destroy-prometheus | ||
|
|
||
| .PHONY: destroy-all | ||
| destroy-all: | ||
| # Note: - prefix ensures errors are ignored and continues | ||
| -${MAKE} destroy-prometheus-example-app | ||
| -${MAKE} destroy-prometheus | ||
| -${MAKE} destroy-prometheus-operator | ||
|
|
||
| .PHONY: deploy-all | ||
| deploy-all: deploy-prometheus-example-app deploy-prometheus | ||
|
|
||
| # Prometheus example app | ||
| .PHONY: deploy-prometheus-example-app | ||
| deploy-prometheus-example-app: | ||
| source "${SCRIPTS_DIR}/${TELEMETRY_SCRIPT}" && deploy-prometheus-example-app | ||
|
|
||
| .PHONY: destroy-prometheus-example-app | ||
| destroy-prometheus-example-app: | ||
| source "${SCRIPTS_DIR}/${TELEMETRY_SCRIPT}" && destroy-prometheus-example-app | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Setup Prometheus | ||
| This folder contains helper files to setup a prometheus instance locally. | ||
|
|
||
| ## Commands | ||
| - Deploy prometheus operator | ||
| - `make deploy-prometheus-operator` | ||
| - Deploy prometheus | ||
| - `make deploy-prometheus` | ||
| - Deploy prometheus example app | ||
| - `make deploy-prometheus-example-app` | ||
| - Deploy all | ||
| `make deploy-all` | ||
| - Destroy all | ||
| `make destroy-all` | ||
|
|
||
| ## Manual Test | ||
| - From `dev` folder deploy the network `make deploy-network` | ||
| - From this folder run `make deploy-all` | ||
| - export prometheus svc port `kubectl port-forward svc/prometheus 9090:9090` | ||
| - browse `http://localhost:9090/tsdb-status` and ensure status are non-zero |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.