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
908 stars 396 forks source link

Howto install datasource plugin into grafana deployment with grafana-operator? #155

Closed Slach closed 3 years ago

Slach commented 4 years ago

As I see, currently, we can only define plugins: section only on GrafanaDashboard custom resource

but, if I try to add GrafanaDashboard with "__inputs" contains DS_SOMETHING it should resolve to exists GrafanaDataSource custom resource which can't be installed cause when we use .spec.datasources[*].type which not exists in default grafana supported datasource plugins with error Could not find plugin definition for data source: vertamedia-clickhouse-datasource

I propose to add plugins: section to Grafana custom resource definition which will use same mechanics as we use in GrafanaDashboard

@pb82 could you look at this issue?

pb82 commented 4 years ago

Datasource plugins, like other types of plugins can be added via the plugins section of the dashboard. If the dashboard has an __inputs section, the inputs need to be mapped: https://github.com/integr8ly/grafana-operator/blob/master/documentation/dashboards.md#datasource-inputs

You should be able to create a datasource even if the type does not exist in Grafana (yet). You will see an error message in Grafana, but as soon as the data source plugin is installed (and Grafana restarted in the process) it should be fine.

I agree that defining plugins in the Grafana CR would be smoother.

pb82 commented 4 years ago

@Slach does the suggested solution work for you?

Slach commented 4 years ago

My Current workaround I just install dummy dashboard with plugins: section before installation my real dashboard

so adding plugins section to Grafana custom resource looks much better

tlipatov-asapp commented 4 years ago

If we can pass custom env vars to the grafana deployment via the operator then we can install the plugins using "GF_INSTALL_PLUGINS"

https://grafana.com/docs/grafana/latest/installation/docker/#install-official-and-community-grafana-plugins

ocervell commented 3 years ago

Any updates here ?

pb82 commented 3 years ago

@ocervell The latest release (3.6.0) allows you to set env vars, so you can try the suggestion from @tlipatov-asapp

ocervell commented 3 years ago

@pb82 thanks for the answer ! Could you help me on how to do it ? I've tried the following and it doesn't seem to work (still getting the message that plugin is not installed...):

Example:

spec:
  ...
  deployment:
    envFrom:
      - secretRef:
          name: grafana-env
apiVersion: v1
kind: Secret
metadata:
  name: grafana-env
  namespace: default
stringData:
  GF_INSTALL_PLUGINS: doitintl-bigquery-datasource 1.0.8

Update: it is working ! I had to un-deploy / re-deploy though.

tlipatov-asapp commented 3 years ago

This is working perfectly, thank you!

pb82 commented 3 years ago

@ocervell hmm, changing the env vars should automatically restart Grafana. Did you have to do something else to get it working?

pb82 commented 3 years ago

@ocervell Also when providing custom env vars you should define the admin credentials in there too, see https://github.com/integr8ly/grafana-operator/blob/master/documentation/env_vars.md#requirements-when-providing-external-admin-credentials

ocervell commented 3 years ago

Can we add a blob to the documentation on installing plugins ? Then we can close this :)

david-martin commented 3 years ago

@ocervell yes, documentation makes sense here. Feel free to propose a PR if you have time