Skip to content

Commit c8b4d72

Browse files
committed
Metrics Follow-Ups
Adding comment for traceability to prometheus alert rules. Move prometheus installation to new script to clean up makefile. Signed-off-by: Daniel Franz <[email protected]>
1 parent ebc7986 commit c8b4d72

File tree

3 files changed

+37
-11
lines changed

3 files changed

+37
-11
lines changed

Makefile

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -277,22 +277,13 @@ test-experimental-e2e: run image-registry prometheus experimental-e2e e2e e2e-me
277277
.PHONY: prometheus
278278
prometheus: PROMETHEUS_NAMESPACE := olmv1-system
279279
prometheus: PROMETHEUS_VERSION := v0.83.0
280-
prometheus: TMPDIR := $(shell mktemp -d)
281280
prometheus: #EXHELP Deploy Prometheus into specified namespace
282-
trap 'echo "Cleaning up $(TMPDIR)"; rm -rf "$(TMPDIR)"' EXIT; \
283-
curl -s "https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/refs/tags/$(PROMETHEUS_VERSION)/kustomization.yaml" > "$(TMPDIR)/kustomization.yaml"; \
284-
curl -s "https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/refs/tags/$(PROMETHEUS_VERSION)/bundle.yaml" > "$(TMPDIR)/bundle.yaml"; \
285-
(cd $(TMPDIR) && $(KUSTOMIZE) edit set namespace $(PROMETHEUS_NAMESPACE)) && kubectl create -k "$(TMPDIR)"
286-
kubectl wait --for=condition=Ready pods -n $(PROMETHEUS_NAMESPACE) -l app.kubernetes.io/name=prometheus-operator
287-
$(KUSTOMIZE) build config/overlays/prometheus | sed "s/cert-git-version/cert-$(VERSION)/g" | kubectl apply -f -
288-
kubectl wait --for=condition=Ready pods -n $(PROMETHEUS_NAMESPACE) -l app.kubernetes.io/name=prometheus-operator --timeout=60s
289-
kubectl wait --for=create pods -n $(PROMETHEUS_NAMESPACE) prometheus-prometheus-0 --timeout=60s
290-
kubectl wait --for=condition=Ready pods -n $(PROMETHEUS_NAMESPACE) prometheus-prometheus-0 --timeout=120s
281+
./hack/test/install-prometheus.sh $(PROMETHEUS_NAMESPACE) $(PROMETHEUS_VERSION) $(KUSTOMIZE) $(VERSION)
291282

292283
# The output alerts.out file contains any alerts, pending or firing, collected during a test run in json format.
293284
.PHONY: e2e-metrics
294285
e2e-metrics: ALERTS_FILE_PATH := $(if $(ARTIFACT_PATH),$(ARTIFACT_PATH),.)/alerts.out
295-
e2e-metrics: #EXHELP Request metrics from prometheus; select only actively firing alerts; place in ARTIFACT_PATH if set
286+
e2e-metrics: #EXHELP Request metrics from prometheus; place in ARTIFACT_PATH if set
296287
curl -X GET http://localhost:30900/api/v1/alerts | jq 'if (.data.alerts | length) > 0 then .data.alerts.[] else empty end' > $(ALERTS_FILE_PATH)
297288

298289
.PHONY: extension-developer-e2e

config/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Overlay containing manifest files which enable prometheus scraping of the catalo
3333

3434
These manifests will not end up in the `manifests/` folder, as they must be applied in two distinct steps to avoid issues with applying prometheus CRDs and CRs simultaneously.
3535

36+
Performance alert settings can be found in: `config/overlays/prometheus/prometheus_rule.yaml`
37+
3638
## config/overlays/experimental
3739

3840
This provides additional configuration used to support experimental features, including CRDs. This configuration requires cert-manager.

hack/test/install-prometheus.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
PROMETHEUS_NAMESPACE="$1"
6+
PROMETHEUS_VERSION="$2"
7+
KUSTOMIZE="$3"
8+
GIT_VERSION="$4"
9+
10+
TMPDIR="$(mktemp -d)"
11+
trap 'echo "Cleaning up $TMPDIR"; rm -rf "$TMPDIR"' EXIT
12+
13+
echo "Downloading Prometheus resources..."
14+
curl -s "https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/refs/tags/${PROMETHEUS_VERSION}/kustomization.yaml" > "${TMPDIR}/kustomization.yaml"
15+
curl -s "https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/refs/tags/${PROMETHEUS_VERSION}/bundle.yaml" > "${TMPDIR}/bundle.yaml"
16+
17+
echo "Patching namespace to ${PROMETHEUS_NAMESPACE}..."
18+
(cd "$TMPDIR" && $KUSTOMIZE edit set namespace "$PROMETHEUS_NAMESPACE")
19+
20+
echo "Applying Prometheus base..."
21+
kubectl apply -k "$TMPDIR" --server-side
22+
23+
echo "Waiting for Prometheus Operator pod to become ready..."
24+
kubectl wait --for=condition=Ready pod -n "$PROMETHEUS_NAMESPACE" -l app.kubernetes.io/name=prometheus-operator
25+
26+
echo "Applying overlay config..."
27+
$KUSTOMIZE build config/overlays/prometheus | sed "s/cert-git-version/cert-${VERSION}/g" | kubectl apply -f -
28+
29+
echo "Waiting for metrics scraper to become ready..."
30+
kubectl wait --for=create pods -n "$PROMETHEUS_NAMESPACE" prometheus-prometheus-0 --timeout=60s
31+
kubectl wait --for=condition=Ready pods -n "$PROMETHEUS_NAMESPACE" prometheus-prometheus-0 --timeout=120s
32+
33+
echo "Prometheus deployment completed successfully."

0 commit comments

Comments
 (0)