Skip to content

Commit

Permalink
feat: deploy PrometheusRule resource for the operator
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
simonpasquier committed Nov 19, 2024
1 parent 490a91d commit fd64aa7
Show file tree
Hide file tree
Showing 21 changed files with 22 additions and 765 deletions.
5 changes: 0 additions & 5 deletions .github/tools
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,4 @@ operator-sdk v1.37.0
opm v1.47.0
promq v0.0.1
crdoc v0.5.2
jsonnet v0.20.0
jsonnetfmt v0.20.0
jsonnet-lint v0.20.0
jb v0.5.1
gojsontoyaml v0.1.0
shellcheck 0.10.0
3 changes: 0 additions & 3 deletions .github/workflows/pr-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ jobs:
- name: Lint Go code
run: make lint-golang

- name: Lint Jsonnet code
run: make fmt-jsonnet lint-jsonnet && git diff --exit-code

- name: Lint Shell scripts
run: make lint-shell

Expand Down
39 changes: 6 additions & 33 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,51 +24,24 @@ test-unit:
go test -cover ./cmd/... ./pkg/...

.PHONY: lint
lint: lint-golang lint-jsonnet lint-shell
lint: lint-golang lint-shell

.PHONY: lint-golang
lint-golang: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) run ./... --fix

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

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

.PHONY: fmt-jsonnet
fmt-jsonnet: $(JSONNETFMT) jsonnet-vendor
find jsonnet/ -name 'vendor' -prune \
-o -name '*.libsonnet' -print \
-o -name '*.jsonnet' -print \
| xargs -n 1 -- $(JSONNETFMT) $(JSONNETFMT_ARGS) -i


.PHONY: check-jq
check-jq:
jq --version > /dev/null

.PHONY: jsonnet-vendor
jsonnet-vendor: $(JB)
cd jsonnet && $(JB) install

.PHONY: generate-prometheus-rules
generate-prometheus-rules: jsonnet-tools check-jq kustomize jsonnet-vendor
for dir in jsonnet/components/*/; do \
component=$$(basename $$dir) ;\
echo "Generating prometheusrule file for $$component" ;\
$(JSONNET) -J $(JSONNET_VENDOR) $$dir/main.jsonnet \
| jq .rule \
| $(GOJSONTOYAML) > deploy/monitoring/monitoring-$$component-rules.yaml ;\
cd deploy/monitoring && \
$(KUSTOMIZE) edit add resource "monitoring-$$component-rules.yaml" && cd - ;\
done;

.PHONY: docs
docs: $(CRDOC)
mkdir -p docs
Expand Down Expand Up @@ -129,7 +102,7 @@ generate-deepcopy: $(CONTROLLER_GEN)
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./pkg/apis/..."

.PHONY: generate
generate: generate-crds generate-deepcopy generate-kustomize generate-package-resources generate-prometheus-rules docs
generate: generate-crds generate-deepcopy generate-kustomize generate-package-resources docs

.PHONY: operator
operator: generate build
Expand Down Expand Up @@ -317,4 +290,4 @@ kind-cluster: $(OPERATOR_SDK)

.PHONY: clean
clean: clean-tools
rm -rf $(JSONNET_VENDOR) bundle/ bundle.Dockerfile
rm -rf bundle/ bundle.Dockerfile
70 changes: 1 addition & 69 deletions Makefile.tools
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,6 @@ OC_VERSION = v4.8.11
CRDOC = $(TOOLS_DIR)/crdoc
CRDOC_VERSION = v0.5.2

# jsonnet related tools and dependencies
JSONNET = $(TOOLS_DIR)/jsonnet
JSONNETFMT = $(TOOLS_DIR)/jsonnetfmt
JSONNET_LINT = $(TOOLS_DIR)/jsonnet-lint
JSONNET_VERSION = v0.20.0

JB = $(TOOLS_DIR)/jb
JB_VERSION = v0.5.1

GOJSONTOYAML = $(TOOLS_DIR)/gojsontoyaml
GOJSONTOYAML_VERSION = v0.1.0

JSONNET_VENDOR = jsonnet/vendor
JSONNETFMT_ARGS = -n 2 --max-blank-lines 2 --string-style s --comment-style s

SHELLCHECK = $(TOOLS_DIR)/shellcheck
SHELLCHECK_VERSION = 0.10.0

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

.PHONY: jsonnet
$(JSONNET) jsonnet: $(TOOLS_DIR)
@{ \
set -ex ;\
[[ -f $(JSONNET) ]] && exit 0 ;\
GOBIN=$(TOOLS_DIR) go install github.com/google/go-jsonnet/cmd/jsonnet@$(JSONNET_VERSION) ;\
}


.PHONY: jsonnetfmt
$(JSONNETFMT) jsonnetfmt: $(TOOLS_DIR)
@{ \
set -ex ;\
[[ -f $(JSONNETFMT) ]] && exit 0 ;\
GOBIN=$(TOOLS_DIR) go install github.com/google/go-jsonnet/cmd/jsonnetfmt@$(JSONNET_VERSION) ;\
}

.PHONY: jsonnet-lint
$(JSONNET_LINT) jsonnet-lint: $(TOOLS_DIR)
@{ \
set -ex ;\
[[ -f $(JSONNET_LINT) ]] && exit 0 ;\
GOBIN=$(TOOLS_DIR) go install github.com/google/go-jsonnet/cmd/jsonnet-lint@$(JSONNET_VERSION) ;\
}

.PHONY: jb
$(JB) jb: $(TOOLS_DIR)
@{ \
set -ex ;\
[[ -f $(JB) ]] && exit 0 ;\
GOBIN=$(TOOLS_DIR) go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@$(JB_VERSION) ;\
}

.PHONY: gojsontoyaml
$(GOJSONTOYAML) gojsontoyaml: $(TOOLS_DIR)
@{ \
set -ex ;\
[[ -f $(GOJSONTOYAML) ]] && exit 0 ;\
GOBIN=$(TOOLS_DIR) go install github.com/brancz/gojsontoyaml@$(GOJSONTOYAML_VERSION) ;\
}

.PHONY: shellcheck
$(SHELLCHECK) shellcheck: $(TOOLS_DIR)
@{ \
Expand All @@ -196,9 +140,6 @@ $(SHELLCHECK) shellcheck: $(TOOLS_DIR)
$(SHELLCHECK) -V | grep -q $${version##v} ;\
}

.PHONY: jsonnet-tools
jsonnet-tools: jsonnet jsonnetfmt jsonnet-lint jb gojsontoyaml

# Install all required tools
.PHONY: tools
tools: $(CONTROLLER_GEN) \
Expand All @@ -209,8 +150,7 @@ tools: $(CONTROLLER_GEN) \
$(PROMQ) \
$(CRDOC) \
$(GOLANGCI_LINT) \
$(SHELLCHECK) \
jsonnet-tools
$(SHELLCHECK)
@{ \
set -ex ;\
tools_file=.github/tools ;\
Expand All @@ -224,11 +164,6 @@ tools: $(CONTROLLER_GEN) \
echo $$(basename $(OPM)) $(OPM_VERSION) >> $$tools_file ;\
echo $$(basename $(PROMQ)) $(PROMQ_VERSION) >> $$tools_file ;\
echo $$(basename $(CRDOC)) $(CRDOC_VERSION) >> $$tools_file ; \
echo $$(basename $(JSONNET)) $(JSONNET_VERSION) >> $$tools_file ;\
echo $$(basename $(JSONNETFMT)) $(JSONNET_VERSION) >> $$tools_file ;\
echo $$(basename $(JSONNET_LINT)) $(JSONNET_VERSION) >> $$tools_file ;\
echo $$(basename $(JB)) $(JB_VERSION) >> $$tools_file ;\
echo $$(basename $(GOJSONTOYAML)) $(GOJSONTOYAML_VERSION) >> $$tools_file ;\
echo $$(basename $(SHELLCHECK)) $(SHELLCHECK_VERSION) >> $$tools_file ;\
}

Expand All @@ -246,7 +181,4 @@ validate-tools:
@$(OPM) version
@$(PROMQ) --help | head -n 2
@$(CRDOC) --help | head -n 3
@$(JSONNETFMT) --version
@$(JSONNET_LINT) --version
@$(JB) --version
@$(SHELLCHECK) -V | head -n 2
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ metadata:
categories: Monitoring
certified: "false"
containerImage: observability-operator:0.4.2
createdAt: "2024-11-18T09:45:14Z"
createdAt: "2024-11-19T13:38:30Z"
description: A Go based Kubernetes operator to setup and manage highly available
Monitoring Stack using Prometheus, Alertmanager and Thanos Querier.
operatorframework.io/cluster-monitoring: "true"
Expand Down
3 changes: 0 additions & 3 deletions deploy/monitoring/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- observability-operator-rules.yaml
- monitoring-alertmanager-rules.yaml
- monitoring-prometheus-rules.yaml
- monitoring-prometheus-operator-rules.yaml
128 changes: 0 additions & 128 deletions deploy/monitoring/monitoring-alertmanager-rules.yaml

This file was deleted.

Loading

0 comments on commit fd64aa7

Please sign in to comment.