|
| 1 | +# Mimir Example |
| 2 | + |
| 3 | +The following explains how to deploy a simple Mimir setup that can be used to test Pyrra. |
| 4 | + |
| 5 | +## Pre-Requisites |
| 6 | + |
| 7 | +- [Helm](https://helm.sh/) |
| 8 | +- Kubernetes Cluster (e.g. via [kind](https://kind.sigs.k8s.io/)) |
| 9 | + |
| 10 | +## Setup |
| 11 | + |
| 12 | +Ensure the Pyrra CRDs are installed in your cluster: |
| 13 | + |
| 14 | +```sh |
| 15 | +kubectl apply -f ./examples/kubernetes/manifests/setup/pyrra-slo-CustomResourceDefinition.yaml |
| 16 | +``` |
| 17 | + |
| 18 | +To setup a mimir test cluster for local development you can run: |
| 19 | + |
| 20 | +```sh |
| 21 | +helm upgrade -i mimir grafana/mimir-distributed --version=5.4.0 -n mimir --create-namespace -f ./examples/mimir/mimir-values.yaml --wait |
| 22 | +``` |
| 23 | + |
| 24 | +This will install the [Mimir Helm Chart](https://github.com/grafana/mimir/tree/main/operations/helm/charts/mimir-distributed) in a minimal configuration. |
| 25 | + |
| 26 | +To access the mimir API we have to port-forrward the mimir-gateway service to our local machine: |
| 27 | + |
| 28 | +```sh |
| 29 | +kubectl port-forward -n mimir svc/mimir-gateway 8080:8080 |
| 30 | +``` |
| 31 | + |
| 32 | +In another terminal session we can verify that everything is working by running: |
| 33 | + |
| 34 | +```sh |
| 35 | +curl localhost:8080 |
| 36 | +``` |
| 37 | + |
| 38 | +which should return `OK`. |
| 39 | + |
| 40 | +## Running Pyrra |
| 41 | + |
| 42 | +To run the Pyrra Operator against Mimir we can use the following command: |
| 43 | + |
| 44 | +```sh |
| 45 | +./pyrra kubernetes --mimir-url=http://localhost:8080 |
| 46 | +``` |
| 47 | + |
| 48 | +Additionally, we can run the Pyrra API and connect it against Mimir and the Pyrra Operator: |
| 49 | + |
| 50 | +```sh |
| 51 | +./pyrra api --prometheus-url=http://localhost:8080/prometheus --api-url=http://localhost:9444 |
| 52 | +``` |
| 53 | + |
| 54 | +We can then access the Pyrra UI at `http://localhost:9099`. |
| 55 | + |
| 56 | +## Deploying a SLO |
| 57 | + |
| 58 | +Lets deploy a simple SLO to test the setup: |
| 59 | + |
| 60 | +```sh |
| 61 | +kubectl apply -f examples/mimir/example-slo.yaml |
| 62 | +``` |
| 63 | + |
| 64 | +The Mimir Operator logs should now indicate that the related Mimir rules have been created. |
| 65 | + |
| 66 | +## Using Mimirtool |
| 67 | + |
| 68 | +We can use the `mimirtool` to interact with the Mimir API. |
| 69 | + |
| 70 | +For setup instructions, you can refer to: <https://grafana.com/docs/mimir/latest/manage/tools/mimirtool/#installation> |
| 71 | + |
| 72 | +We can then configure the `mimirtool` to use the Mimir API: |
| 73 | + |
| 74 | +```sh |
| 75 | +export MIMIR_ADDRESS=http://localhost:8080 |
| 76 | +export MIMIR_TENANT_ID=anonymous |
| 77 | +``` |
| 78 | + |
| 79 | +Now we can list the rules created by Pyrra: |
| 80 | + |
| 81 | +```sh |
| 82 | +mimirtool rules list |
| 83 | +``` |
| 84 | + |
| 85 | +Which should return the following: |
| 86 | + |
| 87 | +``` |
| 88 | +Namespace | Rule Group |
| 89 | +apiserver-read-cluster-latency | apiserver-read-cluster-latency |
| 90 | +``` |
| 91 | + |
| 92 | +## Teardown |
| 93 | + |
| 94 | +You can run `helm uninstall mimir -n mimir` to remove the mimir deployment. |
0 commit comments