Skip to content

Commit 39952c6

Browse files
committed
update readme
1 parent 01f04af commit 39952c6

File tree

2 files changed

+92
-8
lines changed

2 files changed

+92
-8
lines changed

CONTRIBUTING.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Contributing
2+
3+
To regenerate mocks:
4+
5+
```shell
6+
mockgen -source=internal/syncer.go -package=internal -destination=internal/syncermock_test.go
7+
```
8+
9+
To make a release:
10+
11+
```shell
12+
TAG=x.x.x && git tag -a ${TAG} -m "make ${TAG} release" && git push --tags
13+
```

README.md

Lines changed: 79 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,86 @@
1-
# cortex-rule-watcher
1+
# cortex-rule-watcher <a href="https://hub.docker.com/r/slamdev/cortex-rule-watcher"><img alt="status" src="https://img.shields.io/docker/v/slamdev/cortex-rule-watcher"></a>
22

3-
Cortex ruler sidecar to sync PrometheusRule resources
3+
Ruler component in [Cortex](https://github.com/cortexproject/cortex)/[Mimir](https://github.com/grafana/mimir)
4+
does not support rules extraction from [PrometheusRule](https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/user-guides/alerting.md#prometheusrule-labelling) resources.
45

5-
To regenerate mocks:
6+
**cortex-rule-watcher** can help you with that. It can be added as a sidecar container to the ruler deployment and
7+
will watch for the changes in PrometheusRule resources in the cluster. As soon as it sees a change in PrometheusRule resource,
8+
it will dump the PrometheusRule spec to the file, that will be synced by ruler component.
69

7-
```shell
8-
mockgen -source=internal/syncer.go -package=internal -destination=internal/syncermock_test.go
10+
[Click to see a full example](example/example.yaml)
11+
12+
Or use this configuration for [mimir helm chart](https://github.com/grafana/helm-charts/tree/mimir-distributed-2.0.7/charts/mimir-distributed):
13+
14+
```yaml
15+
ruler:
16+
extraContainers:
17+
- name: cortex-rule-watcher
18+
args:
19+
- --rule-path=/local-rules
20+
image: slamdev/cortex-rule-watcher:latest
21+
imagePullPolicy: Always
22+
ports:
23+
- name: http-health
24+
containerPort: 8081
25+
- name: http-metrics
26+
containerPort: 8082
27+
livenessProbe:
28+
httpGet:
29+
path: /healthz
30+
port: 8081
31+
initialDelaySeconds: 15
32+
periodSeconds: 20
33+
readinessProbe:
34+
httpGet:
35+
path: /readyz
36+
port: 8081
37+
initialDelaySeconds: 5
38+
periodSeconds: 10
39+
resources:
40+
requests:
41+
cpu: 10m
42+
memory: 16Mi
43+
volumeMounts:
44+
- name: rules
45+
mountPath: /local-rules
46+
extraVolumes:
47+
- name: rules
48+
emptyDir: { }
49+
extraVolumeMounts:
50+
- name: rules
51+
mountPath: /ruler/fake
52+
extraArgs:
53+
ruler-storage.backend: local
54+
ruler-storage.local.directory: /ruler
955
```
1056
11-
To make a release:
57+
Besides that you have to have a cluster role and binding:
1258
13-
```shell
14-
TAG=x.x.x && git tag -a ${TAG} -m "make ${TAG} release" && git push --tags
59+
```yaml
60+
apiVersion: rbac.authorization.k8s.io/v1
61+
kind: ClusterRole
62+
metadata:
63+
name: mimir-distributed-cortex-rule-watcher
64+
rules:
65+
- apiGroups:
66+
- monitoring.coreos.com
67+
resources:
68+
- prometheusrules
69+
verbs:
70+
- get
71+
- list
72+
- watch
73+
---
74+
apiVersion: rbac.authorization.k8s.io/v1
75+
kind: ClusterRoleBinding
76+
metadata:
77+
name: mimir-distributed-cortex-rule-watcher
78+
roleRef:
79+
apiGroup: rbac.authorization.k8s.io
80+
kind: ClusterRole
81+
name: mimir-distributed-cortex-rule-watcher
82+
subjects:
83+
- kind: ServiceAccount
84+
name: mimir-distributed
85+
namespace: monitoring
1586
```

0 commit comments

Comments
 (0)