Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mimir Support #1221

Merged
merged 12 commits into from
Oct 16, 2024
Merged
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,4 @@ examples/openshift/manifests: examples/openshift/main.jsonnet jsonnet/controller
jsonnetfmt -i examples/openshift/main.jsonnet
jsonnet -m examples/openshift/manifests examples/openshift/main.jsonnet | xargs -I{} sh -c 'cat {} | gojsontoyaml > {}.yaml' -- {}
find examples/openshift/manifests -type f ! -name '*.yaml' -delete

Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,9 @@ rules:
- get
- patch
- update
- apiGroups:
- pyrra.dev
resources:
- servicelevelobjectives/finalizers
verbs:
- update
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,9 @@ rules:
- get
- patch
- update
- apiGroups:
- pyrra.dev
resources:
- servicelevelobjectives/finalizers
verbs:
- update
94 changes: 94 additions & 0 deletions examples/mimir/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Mimir Example

The following explains how to deploy a simple Mimir setup that can be used to test Pyrra.

## Pre-Requisites

- [Helm](https://helm.sh/)
- Kubernetes Cluster (e.g. via [kind](https://kind.sigs.k8s.io/))

## Setup

Ensure the Pyrra CRDs are installed in your cluster:

```sh
kubectl apply -f ./examples/kubernetes/manifests/setup/pyrra-slo-CustomResourceDefinition.yaml
```

To setup a mimir test cluster for local development you can run:

```sh
helm upgrade -i mimir grafana/mimir-distributed --version=5.4.0 -n mimir --create-namespace -f ./examples/mimir/mimir-values.yaml --wait
```

This will install the [Mimir Helm Chart](https://github.com/grafana/mimir/tree/main/operations/helm/charts/mimir-distributed) in a minimal configuration.

To access the mimir API we have to port-forrward the mimir-gateway service to our local machine:

```sh
kubectl port-forward -n mimir svc/mimir-gateway 8080:8080
```

In another terminal session we can verify that everything is working by running:

```sh
curl localhost:8080
```

which should return `OK`.

## Running Pyrra

To run the Pyrra Operator against Mimir we can use the following command:

```sh
./pyrra kubernetes --mimir-url=http://localhost:8080
```

Additionally, we can run the Pyrra API and connect it against Mimir and the Pyrra Operator:

```sh
./pyrra api --prometheus-url=http://localhost:8080/prometheus --api-url=http://localhost:9444
```

We can then access the Pyrra UI at `http://localhost:9099`.

## Deploying a SLO

Lets deploy a simple SLO to test the setup:

```sh
kubectl apply -f examples/mimir/example-slo.yaml
```

The Mimir Operator logs should now indicate that the related Mimir rules have been created.

## Using Mimirtool

We can use the `mimirtool` to interact with the Mimir API.

For setup instructions, you can refer to: <https://grafana.com/docs/mimir/latest/manage/tools/mimirtool/#installation>

We can then configure the `mimirtool` to use the Mimir API:

```sh
export MIMIR_ADDRESS=http://localhost:8080
export MIMIR_TENANT_ID=anonymous
```

Now we can list the rules created by Pyrra:

```sh
mimirtool rules list
```

Which should return the following:

```
Namespace | Rule Group
apiserver-read-cluster-latency | apiserver-read-cluster-latency
```

## Teardown

You can run `helm uninstall mimir -n mimir` to remove the mimir deployment.
18 changes: 18 additions & 0 deletions examples/mimir/example-slo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: pyrra.dev/v1alpha1
kind: ServiceLevelObjective
metadata:
labels:
prometheus: k8s
role: alert-rules
name: apiserver-read-cluster-latency
namespace: default
spec:
description: ""
indicator:
latency:
success:
metric: apiserver_request_sli_duration_seconds_bucket{component="apiserver",scope=~"cluster|",verb=~"LIST|GET",le="5"}
total:
metric: apiserver_request_sli_duration_seconds_count{component="apiserver",scope=~"cluster|",verb=~"LIST|GET"}
target: "99"
window: 2w
56 changes: 56 additions & 0 deletions examples/mimir/mimir-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
alertmanager:
enabled: false
persistentVolume:
enabled: false
replicas: 1

compactor:
enabled: false

distributor:
replicas: 1

ingester:
zoneAwareReplication:
enabled: false
persistentVolume:
enabled: false
replicas: 1

minio:
enabled: true

overrides_exporter:
enabled: false

querier:
replicas: 1

query_frontend:
replicas: 1

query_scheduler:
replicas: 1

ruler:
replicas: 1

ruler_querier:
replicas: 1

ruler_query_scheduler:
replicas: 1

store_gateway:
zoneAwareReplication:
enabled: false
persistentVolume:
enabled: false
replicas: 1

nginx:
enabled: false

gateway:
enabledNonEnterprise: true
replicas: 1
6 changes: 6 additions & 0 deletions examples/openshift/manifests/pyrra-kubernetesClusterRole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,9 @@ rules:
- get
- patch
- update
- apiGroups:
- pyrra.dev
resources:
- servicelevelobjectives/finalizers
verbs:
- update
25 changes: 24 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ require (
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a
golang.org/x/net v0.27.0
google.golang.org/protobuf v1.34.2
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.29.3
k8s.io/apimachinery v0.29.3
k8s.io/client-go v0.29.3
Expand All @@ -28,55 +29,77 @@ require (
)

require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 // indirect
github.com/alecthomas/units v0.0.0-20231202071711-9a357b53e9c9 // indirect
github.com/aws/aws-sdk-go v1.50.0 // indirect
github.com/bboreham/go-loser v0.0.0-20230920113527-fcc2c21820a3 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dennwc/varint v1.0.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/edsrzf/mmap-go v1.1.0 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch/v5 v5.8.0 // indirect
github.com/facette/natsort v0.0.0-20181210072756-2cd4dd1e2dcb // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-logr/zapr v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v5 v5.2.0 // indirect
github.com/golang/glog v1.1.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd // indirect
github.com/imdario/mergo v0.3.16 // 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/klauspost/compress v1.17.9 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/mailru/easyjson v0.7.7 // 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/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // 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.6.1 // indirect
github.com/prometheus/common/sigv4 v0.1.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.opentelemetry.io/otel v1.22.0 // indirect
go.opentelemetry.io/otel/metric v1.22.0 // indirect
go.opentelemetry.io/otel/trace v1.22.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/goleak v1.3.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.29.3 // indirect
k8s.io/component-base v0.29.3 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
Expand Down
Loading
Loading