Grafana Operator: How to manage dashboards across multiple organizations in the same instance #2174
-
Hello everyone, I’m using the Grafana Operator (v5.19.4) to manage dashboards in a Kubernetes environment, and I have a question about handling multiple organizations. My current setup:
apiVersion: grafana.integreatly.org/v1beta1
kind: Grafana
metadata:
name: kube-prometheus-stack-grafana
namespace: monitoring
spec:
external:
url: http://kube-prometheus-stack-grafana.monitoring.svc.cluster.local:80
adminUser:
name: kube-prometheus-stack-grafana
key: admin-user
adminPassword:
name: kube-prometheus-stack-grafana
key: admin-password Here’s an example of one of my GrafanaDashboard CRs: apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
name: hubble-network-overview-namespace
namespace: default
labels:
app: kube-prometheus-stack-grafana
spec:
allowCrossNamespaceImport: true
configMapRef:
name: hubble-network-overview-namespace
key: hubble-network-overview-namespace.json
folder: "Cilium"
instanceSelector:
matchLabels:
app: grafana
resyncPeriod: 10m Main question: Observed behavior (possible bug?):
I couldn’t find any documentation on this— is this normal? Does the operator truly depend on the active session’s organization context? Why does it replicate as I navigate between orgs? What I’ve already tried/researched:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
As of right now, there's no intention to actively support multiple orgs. If you want to use basic authentication, you can "lock" the Operator to a specific org by setting The way around this is by creating a apiVersion: grafana.integreatly.org/v1beta1
kind: Grafana
metadata:
name: main-kube-prometheus-stack-grafana
namespace: monitoring
labels:
app: kube-prometheus-stack-grafana
spec:
client:
headers:
X-Grafana-Org-Id: 1
external:
url: http://kube-prometheus-stack-grafana.monitoring.svc.cluster.local:80
adminUser:
name: kube-prometheus-stack-grafana
key: admin-user
adminPassword:
name: kube-prometheus-stack-grafana
key: admin-password
---
apiVersion: grafana.integreatly.org/v1beta1
kind: Grafana
metadata:
name: dev-kube-prometheus-stack-grafana
namespace: default # Namespaces can be different as long as the URL is valid and the operator can reach it.
labels:
app: kube-prometheus-stack-grafana
spec:
client:
headers:
X-Grafana-Org-Id: 2
external:
url: http://kube-prometheus-stack-grafana.monitoring.svc.cluster.local:80
adminUser:
name: kube-prometheus-stack-grafana
key: admin-user
adminPassword:
name: kube-prometheus-stack-grafana
key: admin-password Then the apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
name: hubble-network-overview-namespace
namespace: default
spec:
allowCrossNamespaceImport: true
configMapRef:
name: hubble-network-overview-namespace
key: hubble-network-overview-namespace.json
folder: "Cilium"
instanceSelector:
matchLabels:
app: kube-prometheus-stack-grafana Did not test the following: |
Beta Was this translation helpful? Give feedback.
As of right now, there's no intention to actively support multiple orgs.
That does however not mean it's impossible.
The operator treats each
Grafana
CR as a unique instance, so if you're reusing credentials, you'll end up in your current scenario where it follows the admin user.If you want to use basic authentication, you can "lock" the Operator to a specific org by setting
X-Grafana-Org-Id
, then regardless of the org you logged into, it will always target the id in the header.The way around this is by creating a
Grafana
CR per org 🙂