External grafana
A basic example configuring an external grafana instance.
In this case we create a grafana instance through the operator just to showcase that it can be done.
Notice the instanceSelector
of the grafana dashboard and the grafana instances.
You will notice that it’s only the grafana instance called external-grafana
that will match with the grafana dashboard called external-grafanadashboard-sample
.
If you look in the status of external-grafana you will also see the hash of the dashboard that have been applied.
kubectl get grafanas.grafana.integreatly.org external-grafana -o yaml
# redacted output
status:
adminUrl: http://test.io
dashboards:
- grafana-operator-system/external-grafanadashboard-sample/cb1688d2-547a-465b-bc49-df3ccf3da883
stage: complete
stageStatus: success
FYI
If you want run the same test locally on your computer remember to ether update the ingres host to match your settings or change client.preferIngress
to false assuming that you run the operator within the cluster.
---
apiVersion: grafana.integreatly.org/v1beta1
kind: Grafana
metadata:
name: grafana
labels:
dashboards: "grafana"
spec:
config:
log:
mode: "console"
auth:
disable_login_form: "false"
security:
admin_user: root
admin_password: secret
ingress:
spec:
ingressClassName: nginx
rules:
- host: test.io
http:
paths:
- backend:
service:
name: grafana-service
port:
number: 3000
path: /
pathType: Prefix
---
# Use the same grafana instance that we just created, notice the ingress config
apiVersion: grafana.integreatly.org/v1beta1
kind: Grafana
metadata:
name: external-grafana
labels:
dashboards: "external-grafana"
spec:
external:
url: http://test.io
adminPassword:
name: grafana-admin-credentials
key: GF_SECURITY_ADMIN_PASSWORD
adminUser:
name: grafana-admin-credentials
key: GF_SECURITY_ADMIN_USER
---
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
name: external-grafanadashboard-sample
spec:
instanceSelector:
matchLabels:
dashboards: "external-grafana"
json: >
{
"id": null,
"title": "Simple Dashboard",
"tags": [],
"style": "dark",
"timezone": "browser",
"editable": true,
"hideControls": false,
"graphTooltip": 1,
"panels": [],
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {
"time_options": [],
"refresh_intervals": []
},
"templating": {
"list": []
},
"annotations": {
"list": []
},
"refresh": "5s",
"schemaVersion": 17,
"version": 0,
"links": []
}