Skip to content

Commit

Permalink
Merge branch 'main' into simple-go-build-test
Browse files Browse the repository at this point in the history
  • Loading branch information
z0rc authored Jul 24, 2023
2 parents f13c3d9 + 89cea6b commit ffe27d0
Show file tree
Hide file tree
Showing 9 changed files with 544 additions and 283 deletions.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ repos:
- id: go-mod-tidy
- id: go-fmt
- id: go-vet-mod
- id: go-lint
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2023 HealthJoy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,50 @@
# Mimir Rules Controller

Kubernetes controller for managing [Mimir](github.com/grafana/mimir) rules as Kubernetes resources.
This controller heavily inspired by [Prometheus Operator](github.com/coreos/prometheus-operator)
and [Thanos Rule Controller](github.com/thanos-io/thanos/tree/master/pkg/operator/rule).

## Installation

Use the package manager [helm](https://helm.sh/) to install Mimir Rules Controller. You need to specify the address of your mimir installation and cluster name.

```bash
helm install --set mimir.address=mimir.example.com --set mimir.clusterName=example-cluster mimir-rules-controller ./deployments/charts/mimir-rules-controller
```

That will install CRDs and the controller itself.

## Usage

To add rules or alerts for Mimir using the controller, you need to create a custom resource in a cluster with the installed controller:

```yaml
apiVersion: rulescontroller.k8s.healthjoy.com/v1alpha1
kind: MimirRule
metadata:
name: example-mimirrule
namespace: default
spec:
groups:
- name: example-mimirrule
rules:
- alert: example-mimirrule
expr: 1
for: 1m
labels:
severity: critical
annotations:
summary: example-mimirrule
description: example-mimirrule
```
## Contributing
Pull requests are welcome. For major changes, please open an issue first
to discuss what you would like to change.
Please make sure to update tests as appropriate.
## License
[MIT](https://choosealicense.com/licenses/mit/)
4 changes: 2 additions & 2 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1.2.1
FROM golang:1.19.4-alpine AS builder
FROM golang:1.20.4-alpine AS builder
WORKDIR /go/src/github.com/healthjoy/mimir-rules-controller
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/root/.cache/go-build \
Expand All @@ -11,6 +11,6 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
cd cmd/controller \
&& CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o /go/bin/mimir-rules-controller

FROM alpine:3.17.0
FROM alpine:3.18.0
COPY --from=builder /go/bin/mimir-rules-controller /bin/mimir-rules-controller
ENTRYPOINT ["/bin/mimir-rules-controller"]
4 changes: 2 additions & 2 deletions deployments/charts/mimir-rules-controller/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: mimir-rules-controller
description: A Helm chart for Mimir Rules Controller
type: application
version: 0.1.0
appVersion: 0.1.1
version: 0.1.3
appVersion: 0.1.3
113 changes: 53 additions & 60 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,105 +1,98 @@
module github.com/healthjoy/mimir-rules-controller

go 1.19
go 1.20

require (
github.com/grafana/mimir v0.0.0-20221028073401-32137ee2c4c4
github.com/prometheus/client_golang v1.14.0
github.com/prometheus/common v0.37.0
github.com/prometheus/prometheus v1.8.2-0.20220308163432-03831554a519
github.com/grafana/mimir v0.0.0-20230331094428-7e508c3b026b
github.com/prometheus/client_golang v1.16.0
github.com/prometheus/common v0.44.0
github.com/prometheus/prometheus v1.8.2-0.20220620125440-d7e7b8e04b5e
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.26.0
k8s.io/apimachinery v0.26.0
k8s.io/client-go v0.26.0
k8s.io/klog/v2 v2.80.1
sigs.k8s.io/controller-runtime v0.14.0
k8s.io/api v0.27.4
k8s.io/apimachinery v0.27.4
k8s.io/client-go v0.27.4
k8s.io/klog/v2 v2.100.1
sigs.k8s.io/controller-runtime v0.15.0
)

replace github.com/prometheus/prometheus => github.com/grafana/mimir-prometheus v0.0.0-20230331082743-9fe1bd2d63f8

require (
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
github.com/aws/aws-sdk-go v1.44.109 // indirect
github.com/aws/aws-sdk-go v1.44.233 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dennwc/varint v1.0.0 // indirect
github.com/edsrzf/mmap-go v1.1.0 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/efficientgo/core v1.0.0-rc.2 // indirect
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/grafana/dskit v0.0.0-20221004074252-e8057f223e41 // indirect
github.com/grafana/regexp v0.0.0-20221005093135-b4c2bcb0a4b6 // indirect
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0-rc.2.0.20201207153454-9f6bf00c00a7 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/grafana/dskit v0.0.0-20230317135621-727cbc22c1fe // indirect
github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd // indirect
github.com/hashicorp/golang-lru/v2 v2.0.2 // indirect
github.com/imdario/mergo v0.3.15 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common/sigv4 v0.1.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.8.0 // indirect
github.com/thanos-io/thanos v0.26.1-0.20220602051129-a6f6ce060ed4 // indirect
github.com/weaveworks/common v0.0.0-20220915171148-7b5f6f3e74bc // indirect
github.com/stretchr/testify v1.8.2 // indirect
github.com/thanos-io/objstore v0.0.0-20230306180455-fb5482c10670 // indirect
github.com/weaveworks/common v0.0.0-20230315122012-918bab8e5f88 // indirect
github.com/weaveworks/promrus v1.2.0 // indirect
go.opentelemetry.io/contrib/propagators/ot v1.4.0 // indirect
go.opentelemetry.io/otel v1.7.0 // indirect
go.opentelemetry.io/otel/bridge/opentracing v1.5.0 // indirect
go.opentelemetry.io/otel/sdk v1.7.0 // indirect
go.opentelemetry.io/otel/trace v1.7.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/goleak v1.2.0 // indirect
golang.org/x/net v0.3.1-0.20221206200815-1e63c2f08a10 // indirect
golang.org/x/oauth2 v0.0.0-20220628200809-02e64fa58f26 // indirect
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/term v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
go.opentelemetry.io/otel v1.14.0 // indirect
go.opentelemetry.io/otel/trace v1.14.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/goleak v1.2.1 // indirect
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/oauth2 v0.8.0 // indirect
golang.org/x/sync v0.2.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/term v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220628213854-d9e0b6570c03 // indirect
google.golang.org/grpc v1.47.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect
google.golang.org/genproto v0.0.0-20230330200707-38013875ee22 // indirect
google.golang.org/grpc v1.54.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
k8s.io/utils v0.0.0-20230313181309-38a27ef9d749 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace (
github.com/docker/distribution v2.7.1+incompatible => github.com/docker/distribution v2.8.0+incompatible
github.com/prometheus/prometheus => github.com/grafana/mimir-prometheus v0.0.0-20221007080257-ecc05616ec93
github.com/thanos-io/thanos => github.com/grafana/thanos v0.19.1-0.20220713162227-7bde03e4afa9
)
Loading

0 comments on commit ffe27d0

Please sign in to comment.