Skip to content

Commit 1ae258f

Browse files
pedjakclaude
andcommitted
refactor: migrate e2e prometheus from custom chart to kube-prometheus-stack
Replace the hand-rolled prometheus-operator install script and custom Helm chart (helm/prometheus/) with the official kube-prometheus-stack community chart (v86.2.2), installed from OCI registry. - Disable all unused components (grafana, alertmanager, exporters, default rules, admission webhooks, operator TLS) - Configure Prometheus instance, NetworkPolicies, and kubelet ServiceMonitor via chart values - Add operator-controller and catalogd ServiceMonitors as additionalServiceMonitors using bearerTokenFile (projected SA token) instead of the legacy prometheus-metrics-token Secret - Split PrometheusRules into controller-panic-alerts and controller-resource-alerts so the experimental override only replaces the resource-usage group - Inline the install logic into the Makefile prometheus target - Remove conftest prometheus-networkpolicies.rego policy (NetworkPolicy now managed by the chart) - Remove unused kustomize bingo tooling Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 23b7e52 commit 1ae258f

26 files changed

Lines changed: 284 additions & 611 deletions

.bingo/Variables.mk

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,6 @@ $(KUBE_SCORE): $(BINGO_DIR)/kube-score.mod
7777
@echo "(re)installing $(GOBIN)/kube-score-v1.20.0"
7878
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=kube-score.mod -o=$(GOBIN)/kube-score-v1.20.0 "github.com/zegl/kube-score/cmd/kube-score"
7979

80-
KUSTOMIZE := $(GOBIN)/kustomize-v5.7.1
81-
$(KUSTOMIZE): $(BINGO_DIR)/kustomize.mod
82-
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
83-
@echo "(re)installing $(GOBIN)/kustomize-v5.7.1"
84-
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=kustomize.mod -o=$(GOBIN)/kustomize-v5.7.1 "sigs.k8s.io/kustomize/kustomize/v5"
85-
8680
OPERATOR_SDK := $(GOBIN)/operator-sdk-v1.41.1
8781
$(OPERATOR_SDK): $(BINGO_DIR)/operator-sdk.mod
8882
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.

.bingo/kustomize.mod

Lines changed: 0 additions & 5 deletions
This file was deleted.

.bingo/kustomize.sum

Lines changed: 0 additions & 87 deletions
This file was deleted.

.bingo/variables.env

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ KIND="${GOBIN}/kind-v0.32.0"
2828

2929
KUBE_SCORE="${GOBIN}/kube-score-v1.20.0"
3030

31-
KUSTOMIZE="${GOBIN}/kustomize-v5.7.1"
32-
3331
OPERATOR_SDK="${GOBIN}/operator-sdk-v1.41.1"
3432

3533
OPM="${GOBIN}/opm-v1.60.0"

AGENTS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ make generate
165165
│ │ ├── base/ # Base manifests & CRDs
166166
│ │ ├── templates/ # Helm templates
167167
│ │ └── values.yaml # Default values
168-
│ └── prometheus/ # Prometheus monitoring
168+
├── testdata/
169+
│ └── prometheus/ # kube-prometheus-stack values for e2e monitoring
169170
├── test/ # Test suites
170171
│ ├── e2e/ # End-to-end tests (see test/e2e/README.md)
171172
│ ├── extension-developer-e2e/ # Extension developer tests

Makefile

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ ifeq ($(shell [[ $$HOME == "" || $$HOME == "/" ]] && [[ $$XDG_DATA_HOME == "" ]]
5555
SETUP_ENVTEST_BIN_DIR_OVERRIDE += --bin-dir /tmp/envtest-binaries
5656
endif
5757

58-
# bingo manages consistent tooling versions for things like kind, kustomize, etc.
58+
# bingo manages consistent tooling versions for things like kind, etc.
5959
include .bingo/Variables.mk
6060

6161
ifeq ($(origin KIND_CLUSTER_NAME), undefined)
@@ -124,8 +124,7 @@ lint: lint-custom $(GOLANGCI_LINT) #HELP Run golangci linter.
124124
.PHONY: lint-helm
125125
lint-helm: $(HELM) $(CONFTEST) #HELP Run helm linter
126126
helm lint helm/olmv1
127-
helm lint helm/prometheus
128-
(set -euo pipefail; helm template olmv1 helm/olmv1; helm template prometheus helm/prometheus) | $(CONFTEST) test --policy hack/conftest/policy/ --combine -n main -n prometheus -
127+
(set -euo pipefail; helm template olmv1 helm/olmv1) | $(CONFTEST) test --policy hack/conftest/policy/ --combine -n main -
129128

130129
.PHONY: lint-deployed-resources
131130
lint-deployed-resources: $(KUBE_SCORE) #EXHELP Lint deployed resources.
@@ -338,18 +337,28 @@ test-experimental-e2e: GO_BUILD_EXTRA_FLAGS := -cover
338337
test-experimental-e2e: COVERAGE_NAME := experimental-e2e
339338
test-experimental-e2e: export MANIFEST := $(EXPERIMENTAL_RELEASE_MANIFEST)
340339
test-experimental-e2e: export INSTALL_DEFAULT_CATALOGS := false
341-
test-experimental-e2e: PROMETHEUS_VALUES := helm/prom_experimental.yaml
340+
test-experimental-e2e: PROMETHEUS_VALUES := testdata/prometheus/values-experimental.yaml
342341
test-experimental-e2e: E2E_TIMEOUT ?= 25m
343342
test-experimental-e2e: run-internal prometheus e2e e2e-coverage kind-clean #HELP Run experimental e2e test suite on local kind cluster
344343

344+
CATALOGD_CERT_SECRET = catalogd-service-cert-$(VERSION)
345+
345346
.PHONY: prometheus
346347
prometheus: PROMETHEUS_NAMESPACE := olmv1-system
347-
prometheus: PROMETHEUS_VERSION := v0.83.0
348-
prometheus: $(KUSTOMIZE) #EXHELP Deploy Prometheus into specified namespace
348+
prometheus: PROMETHEUS_CHART_VERSION := 86.2.2
349+
prometheus: $(HELM) #EXHELP Deploy Prometheus into specified namespace
349350
ifeq ($(strip $(E2E_SUMMARY_OUTPUT)),)
350351
@echo "E2E_SUMMARY_OUTPUT unset; skipping prometheus deployment"
351352
else
352-
./hack/test/install-prometheus.sh $(PROMETHEUS_NAMESPACE) $(PROMETHEUS_VERSION) $(VERSION) $(PROMETHEUS_VALUES)
353+
$(HELM) upgrade --install prometheus oci://ghcr.io/prometheus-community/charts/kube-prometheus-stack \
354+
--namespace $(PROMETHEUS_NAMESPACE) --create-namespace \
355+
--version $(PROMETHEUS_CHART_VERSION) \
356+
-f testdata/prometheus/values.yaml \
357+
$(if $(PROMETHEUS_VALUES),-f $(PROMETHEUS_VALUES)) \
358+
--set-string 'prometheus.additionalServiceMonitors[1].endpoints[0].tlsConfig.ca.secret.name=$(CATALOGD_CERT_SECRET)' \
359+
--set-string 'prometheus.additionalServiceMonitors[1].endpoints[0].tlsConfig.cert.secret.name=$(CATALOGD_CERT_SECRET)' \
360+
--set-string 'prometheus.additionalServiceMonitors[1].endpoints[0].tlsConfig.keySecret.name=$(CATALOGD_CERT_SECRET)' \
361+
--wait --timeout 5m
353362
endif
354363

355364
.PHONY: test-extension-developer-e2e

hack/conftest/policy/README.md

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,51 +20,21 @@ Validates core OLM NetworkPolicy requirements:
2020
- Ingress on port 8443 (Prometheus metrics scraping)
2121
- General egress enabled (for pulling bundle images, connecting to catalogd, and Kubernetes API)
2222

23-
### prometheus-networkpolicies.rego
24-
25-
Package: `prometheus`
26-
27-
Validates Prometheus NetworkPolicy requirements:
28-
29-
- Ensures a NetworkPolicy exists that allows both ingress and egress traffic for prometheus pods
30-
3123
## Usage
3224

3325
These policies are automatically run as part of:
3426

35-
- `make lint-helm` - Validates both helm/olmv1 and helm/prometheus charts (runs `main` and `prometheus` packages)
36-
- `make manifests` - Generates and validates core OLM manifests using only `main` package policies
37-
(Prometheus policies are intentionally skipped here, even if manifests include Prometheus resources;
38-
they are validated via `make lint-helm`)
27+
- `make lint-helm` - Validates the helm/olmv1 chart (runs `main` package)
28+
- `make manifests` - Generates and validates core OLM manifests using `main` package policies
3929

4030
### Running manually
4131

4232
```bash
43-
# Run all policies (main + prometheus namespaces)
44-
(helm template olmv1 helm/olmv1; helm template prometheus helm/prometheus) | conftest test --policy hack/conftest/policy/ --combine -n main -n prometheus -
45-
46-
# Run only OLM policies
4733
helm template olmv1 helm/olmv1 | conftest test --policy hack/conftest/policy/ --combine -n main -
48-
49-
# Run only prometheus policies
50-
helm template prometheus helm/prometheus | conftest test --policy hack/conftest/policy/ --combine -n prometheus -
51-
```
52-
53-
### Excluding policies
54-
55-
Use the `-n` (namespace) flag to selectively run policies:
56-
57-
```bash
58-
# Skip prometheus policies
59-
conftest test --policy hack/conftest/policy/ --combine -n main <input>
60-
61-
# Skip OLM policies
62-
conftest test --policy hack/conftest/policy/ --combine -n prometheus <input>
6334
```
6435

6536
## Adding New Policies
6637

6738
1. Add new rules to an existing `.rego` file or create a new one
6839
2. Use `package main` for policies that should run by default on all manifests
69-
3. Use a custom package name (e.g., `package prometheus`) for optional policies
70-
4. Update the Makefile targets if new namespaces need to be included
40+
3. Update the Makefile targets if new namespaces need to be included

hack/conftest/policy/prometheus-networkpolicies.rego

Lines changed: 0 additions & 33 deletions
This file was deleted.

hack/test/install-prometheus.sh

Lines changed: 0 additions & 54 deletions
This file was deleted.

helm/prom_experimental.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)