grafana / grafana-operator

An operator for Grafana that installs and manages Grafana instances, Dashboards and Datasources through Kubernetes/OpenShift CRs
https://grafana.github.io/grafana-operator/
Apache License 2.0
863 stars 384 forks source link

External grafana config #1587

Closed jade-tseng closed 2 months ago

jade-tseng commented 2 months ago

I have deployed grafana-operator via kustomize into my cluster with existing grafana deployment. The grafana-operator resources are up and now I want to deploy a Grafana (Grafanas.grafana.integreatly.org/v1beta1) and GrafanaDashboard resource using this config:

apiVersion: grafana.integreatly.org/v1beta1
kind: Grafana
metadata:
  name: grafana
  namespace: grafana
  labels:
    dashboards: grafana
spec:
  external:
    url: "https://grafana.myhost.com"
  adminUser: 
    name: grafana-creds
    key: admin-user
  adminPassword: 
    name: grafana-creds
    key: admin-password

Using documentation here and here I expected the admin credentials to be passed from an existing kubernetes secret. I get errors that the CR doesn't expect these fields:

Error from server (BadRequest): error when creating "grafana-cloud.yaml": Grafana in version "v1beta1" cannot be handled as a Grafana: strict decoding error: unknown field "spec.admin_password", unknown field "spec.admin_username"

Error from server (BadRequest): error when creating "grafana-cloud.yaml": Grafana in version "v1beta1" cannot be handled as a Grafana: strict decoding error: unknown field "spec.adminPassword", unknown field "spec.adminUser"

Expected behaviour: Grafana deploys and will sync dashboards to my deployment

How can I pass my grafana admin credentials via k8s secret?