Skip to content

Commit a63fe12

Browse files
feat: deploy PrometheusRule resource for the operator (#629)
This change deploys a PrometheusRule resource with one alerting rule firing when one controller hits more than 10% of failed reconciliations in the last 5 minutes for more than 15 minutes. It also removes "legacy" monitoring resources which were part of the initial attempt to monitor the cluster observability operator but that effort was never finalized. Signed-off-by: Simon Pasquier <[email protected]>
1 parent 490a91d commit a63fe12

21 files changed

+22
-765
lines changed

.github/tools

-5
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,4 @@ operator-sdk v1.37.0
88
opm v1.47.0
99
promq v0.0.1
1010
crdoc v0.5.2
11-
jsonnet v0.20.0
12-
jsonnetfmt v0.20.0
13-
jsonnet-lint v0.20.0
14-
jb v0.5.1
15-
gojsontoyaml v0.1.0
1611
shellcheck 0.10.0

.github/workflows/pr-checks.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ jobs:
3939
- name: Lint Go code
4040
run: make lint-golang
4141

42-
- name: Lint Jsonnet code
43-
run: make fmt-jsonnet lint-jsonnet && git diff --exit-code
44-
4542
- name: Lint Shell scripts
4643
run: make lint-shell
4744

Makefile

+6-33
Original file line numberDiff line numberDiff line change
@@ -24,51 +24,24 @@ test-unit:
2424
go test -cover ./cmd/... ./pkg/...
2525

2626
.PHONY: lint
27-
lint: lint-golang lint-jsonnet lint-shell
27+
lint: lint-golang lint-shell
2828

2929
.PHONY: lint-golang
3030
lint-golang: $(GOLANGCI_LINT)
3131
$(GOLANGCI_LINT) run ./... --fix
3232

33-
.PHONY: lint-jsonnet
34-
lint-jsonnet: $(JSONNET_LINT) jsonnet-vendor
35-
find jsonnet/ -name 'vendor' -prune \
36-
-o -name '*.libsonnet' -print \
37-
-o -name '*.jsonnet' -print \
38-
| xargs -n 1 -- $(JSONNET_LINT) -J $(JSONNET_VENDOR)
33+
# TODO(simonpasquier): remove this after #629 merges.
34+
.PHONY: lint-jsonnet fmt-jsonnet
35+
lint-jsonnet fmt-jsonnet:
3936

4037
.PHONY: lint-shell
4138
lint-shell: $(SHELLCHECK)
4239
find -name "*.sh" -print0 | xargs --null $(SHELLCHECK)
4340

44-
.PHONY: fmt-jsonnet
45-
fmt-jsonnet: $(JSONNETFMT) jsonnet-vendor
46-
find jsonnet/ -name 'vendor' -prune \
47-
-o -name '*.libsonnet' -print \
48-
-o -name '*.jsonnet' -print \
49-
| xargs -n 1 -- $(JSONNETFMT) $(JSONNETFMT_ARGS) -i
50-
51-
5241
.PHONY: check-jq
5342
check-jq:
5443
jq --version > /dev/null
5544

56-
.PHONY: jsonnet-vendor
57-
jsonnet-vendor: $(JB)
58-
cd jsonnet && $(JB) install
59-
60-
.PHONY: generate-prometheus-rules
61-
generate-prometheus-rules: jsonnet-tools check-jq kustomize jsonnet-vendor
62-
for dir in jsonnet/components/*/; do \
63-
component=$$(basename $$dir) ;\
64-
echo "Generating prometheusrule file for $$component" ;\
65-
$(JSONNET) -J $(JSONNET_VENDOR) $$dir/main.jsonnet \
66-
| jq .rule \
67-
| $(GOJSONTOYAML) > deploy/monitoring/monitoring-$$component-rules.yaml ;\
68-
cd deploy/monitoring && \
69-
$(KUSTOMIZE) edit add resource "monitoring-$$component-rules.yaml" && cd - ;\
70-
done;
71-
7245
.PHONY: docs
7346
docs: $(CRDOC)
7447
mkdir -p docs
@@ -129,7 +102,7 @@ generate-deepcopy: $(CONTROLLER_GEN)
129102
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./pkg/apis/..."
130103

131104
.PHONY: generate
132-
generate: generate-crds generate-deepcopy generate-kustomize generate-package-resources generate-prometheus-rules docs
105+
generate: generate-crds generate-deepcopy generate-kustomize generate-package-resources docs
133106

134107
.PHONY: operator
135108
operator: generate build
@@ -317,4 +290,4 @@ kind-cluster: $(OPERATOR_SDK)
317290

318291
.PHONY: clean
319292
clean: clean-tools
320-
rm -rf $(JSONNET_VENDOR) bundle/ bundle.Dockerfile
293+
rm -rf bundle/ bundle.Dockerfile

Makefile.tools

+1-69
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,6 @@ OC_VERSION = v4.8.11
3434
CRDOC = $(TOOLS_DIR)/crdoc
3535
CRDOC_VERSION = v0.5.2
3636

37-
# jsonnet related tools and dependencies
38-
JSONNET = $(TOOLS_DIR)/jsonnet
39-
JSONNETFMT = $(TOOLS_DIR)/jsonnetfmt
40-
JSONNET_LINT = $(TOOLS_DIR)/jsonnet-lint
41-
JSONNET_VERSION = v0.20.0
42-
43-
JB = $(TOOLS_DIR)/jb
44-
JB_VERSION = v0.5.1
45-
46-
GOJSONTOYAML = $(TOOLS_DIR)/gojsontoyaml
47-
GOJSONTOYAML_VERSION = v0.1.0
48-
49-
JSONNET_VENDOR = jsonnet/vendor
50-
JSONNETFMT_ARGS = -n 2 --max-blank-lines 2 --string-style s --comment-style s
51-
5237
SHELLCHECK = $(TOOLS_DIR)/shellcheck
5338
SHELLCHECK_VERSION = 0.10.0
5439

@@ -141,47 +126,6 @@ $(CRDOC) crdoc: $(TOOLS_DIR)
141126
GOBIN=$(TOOLS_DIR) go install fybrik.io/crdoc@$(CRDOC_VERSION) ;\
142127
}
143128

144-
.PHONY: jsonnet
145-
$(JSONNET) jsonnet: $(TOOLS_DIR)
146-
@{ \
147-
set -ex ;\
148-
[[ -f $(JSONNET) ]] && exit 0 ;\
149-
GOBIN=$(TOOLS_DIR) go install github.com/google/go-jsonnet/cmd/jsonnet@$(JSONNET_VERSION) ;\
150-
}
151-
152-
153-
.PHONY: jsonnetfmt
154-
$(JSONNETFMT) jsonnetfmt: $(TOOLS_DIR)
155-
@{ \
156-
set -ex ;\
157-
[[ -f $(JSONNETFMT) ]] && exit 0 ;\
158-
GOBIN=$(TOOLS_DIR) go install github.com/google/go-jsonnet/cmd/jsonnetfmt@$(JSONNET_VERSION) ;\
159-
}
160-
161-
.PHONY: jsonnet-lint
162-
$(JSONNET_LINT) jsonnet-lint: $(TOOLS_DIR)
163-
@{ \
164-
set -ex ;\
165-
[[ -f $(JSONNET_LINT) ]] && exit 0 ;\
166-
GOBIN=$(TOOLS_DIR) go install github.com/google/go-jsonnet/cmd/jsonnet-lint@$(JSONNET_VERSION) ;\
167-
}
168-
169-
.PHONY: jb
170-
$(JB) jb: $(TOOLS_DIR)
171-
@{ \
172-
set -ex ;\
173-
[[ -f $(JB) ]] && exit 0 ;\
174-
GOBIN=$(TOOLS_DIR) go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@$(JB_VERSION) ;\
175-
}
176-
177-
.PHONY: gojsontoyaml
178-
$(GOJSONTOYAML) gojsontoyaml: $(TOOLS_DIR)
179-
@{ \
180-
set -ex ;\
181-
[[ -f $(GOJSONTOYAML) ]] && exit 0 ;\
182-
GOBIN=$(TOOLS_DIR) go install github.com/brancz/gojsontoyaml@$(GOJSONTOYAML_VERSION) ;\
183-
}
184-
185129
.PHONY: shellcheck
186130
$(SHELLCHECK) shellcheck: $(TOOLS_DIR)
187131
@{ \
@@ -196,9 +140,6 @@ $(SHELLCHECK) shellcheck: $(TOOLS_DIR)
196140
$(SHELLCHECK) -V | grep -q $${version##v} ;\
197141
}
198142

199-
.PHONY: jsonnet-tools
200-
jsonnet-tools: jsonnet jsonnetfmt jsonnet-lint jb gojsontoyaml
201-
202143
# Install all required tools
203144
.PHONY: tools
204145
tools: $(CONTROLLER_GEN) \
@@ -209,8 +150,7 @@ tools: $(CONTROLLER_GEN) \
209150
$(PROMQ) \
210151
$(CRDOC) \
211152
$(GOLANGCI_LINT) \
212-
$(SHELLCHECK) \
213-
jsonnet-tools
153+
$(SHELLCHECK)
214154
@{ \
215155
set -ex ;\
216156
tools_file=.github/tools ;\
@@ -224,11 +164,6 @@ tools: $(CONTROLLER_GEN) \
224164
echo $$(basename $(OPM)) $(OPM_VERSION) >> $$tools_file ;\
225165
echo $$(basename $(PROMQ)) $(PROMQ_VERSION) >> $$tools_file ;\
226166
echo $$(basename $(CRDOC)) $(CRDOC_VERSION) >> $$tools_file ; \
227-
echo $$(basename $(JSONNET)) $(JSONNET_VERSION) >> $$tools_file ;\
228-
echo $$(basename $(JSONNETFMT)) $(JSONNET_VERSION) >> $$tools_file ;\
229-
echo $$(basename $(JSONNET_LINT)) $(JSONNET_VERSION) >> $$tools_file ;\
230-
echo $$(basename $(JB)) $(JB_VERSION) >> $$tools_file ;\
231-
echo $$(basename $(GOJSONTOYAML)) $(GOJSONTOYAML_VERSION) >> $$tools_file ;\
232167
echo $$(basename $(SHELLCHECK)) $(SHELLCHECK_VERSION) >> $$tools_file ;\
233168
}
234169

@@ -246,7 +181,4 @@ validate-tools:
246181
@$(OPM) version
247182
@$(PROMQ) --help | head -n 2
248183
@$(CRDOC) --help | head -n 3
249-
@$(JSONNETFMT) --version
250-
@$(JSONNET_LINT) --version
251-
@$(JB) --version
252184
@$(SHELLCHECK) -V | head -n 2

bundle/manifests/observability-operator.clusterserviceversion.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ metadata:
4242
categories: Monitoring
4343
certified: "false"
4444
containerImage: observability-operator:0.4.2
45-
createdAt: "2024-11-18T09:45:14Z"
45+
createdAt: "2024-11-19T13:38:30Z"
4646
description: A Go based Kubernetes operator to setup and manage highly available
4747
Monitoring Stack using Prometheus, Alertmanager and Thanos Querier.
4848
operatorframework.io/cluster-monitoring: "true"

deploy/monitoring/kustomization.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,3 @@ apiVersion: kustomize.config.k8s.io/v1beta1
22
kind: Kustomization
33
resources:
44
- observability-operator-rules.yaml
5-
- monitoring-alertmanager-rules.yaml
6-
- monitoring-prometheus-rules.yaml
7-
- monitoring-prometheus-operator-rules.yaml

deploy/monitoring/monitoring-alertmanager-rules.yaml

-128
This file was deleted.

0 commit comments

Comments
 (0)