https://github.com/martinrusev/grafana-operator
https://github.com/martinrusev/grafana-operator
charm juju
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/martinrusev/grafana-operator
- Owner: martinrusev
- License: apache-2.0
- Created: 2021-03-18T18:28:46.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-05-05T20:26:27.000Z (about 4 years ago)
- Last Synced: 2025-01-15T10:06:41.388Z (4 months ago)
- Topics: charm, juju
- Language: Python
- Homepage:
- Size: 101 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# grafana-operator
## Description
This is the Grafana charm for Kubernetes using the Python Operator Framework.
## Usage
### Deploying
```
$ git clone https://github.com/martinrusev/grafana-operator
$ cd grafana-operator$ sudo snap install charmcraft --beta
$ charmcraft build
Created 'grafana.charm'.$ juju deploy ./grafana.charm --resource grafana-image=grafana/grafana:7.4.5
$ juju status canonical-grafana-charm
Model Controller Cloud/Region Version SLA Timestamp
grafana pebble microk8s/localhost 2.9-rc7 unsupported 16:36:06+01:00App Version Status Scale Charm Store Channel Rev OS Address Message
grafana active 1 grafana local 9 ubuntu grafana startedUnit Workload Agent Address Ports Message
grafana/0* active idle 10.1.243.208 grafana started
```Visit that IP address at port 3000 in your browser and you should see the Grafana web UI. For example, http://10.1.243.208:3000/
### Adding a data source
Adding Prometheus as a data source:
```
$ juju deploy cs:~charmcraft/prometheus-3
$ juju relate grafana prometheus# The juju model in which grafana is installed corresponds to the k8s namespace
$ kubectl get pods -n grafanaNAME READY STATUS RESTARTS AGE
modeloperator-89dd64b8-58sbh 1/1 Running 4 2d4h
prometheus-operator-0 1/1 Running 2 7h31m
prometheus-0 1/1 Running 2 7h31m
grafana-0 2/2 Running 0 21m$ kubectl exec -n grafana grafana-0 -c grafana -- cat /etc/grafana/provisioning/datasources/datasources.yaml
apiVersion: 1
datasources:
- access: proxy
isDefault: 'true'
name: prometheus_36
orgId: '1'
type: prometheus
url: http://10.152.183.88:9090
deleteDatasources: []
```### Importing dashboards
```
juju run-action --wait grafana/0 import-dashboard dashboard="$(base64 mydashboard.json)"
```## Debugging
To check the logs generated by Grafana
```
# The juju model in which grafana is installed corresponds to the k8s namespace
$ kubectl get pods -n grafanaNAME READY STATUS RESTARTS AGE
modeloperator-89dd64b8-58sbh 1/1 Running 4 2d4h
prometheus-operator-0 1/1 Running 2 7h31m
prometheus-0 1/1 Running 2 7h31m
grafana-0 2/2 Running 0 21m$ kubectl exec -n grafana grafana-0 -c grafana -- cat /var/log/grafana/grafana.log
```## Developing
Create and activate a virtualenv with the development requirements:
```
virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements-dev.txt
```To update the ingress library:
```
charmcraft fetch-lib charms.ingress.v0.ingress
```## Testing
The Python operator framework includes a very nice harness for testing
operator behaviour without full deployment. Just `run_tests`:```
./run_tests
```## Roadmap
The Grafana Charm is still a work in progress.
Here are some of the things coming soon:
- [ ] Import a Custom config file
- [x] Ingress Support
- [x] MySQL relation
- [x] Prometheus Datasource
- [x] Dashboard import action