grafana / helm-charts

Apache License 2.0
1.59k stars 2.24k forks source link

Loading custom plugin #2610

Open Jyoti492 opened 1 year ago

Jyoti492 commented 1 year ago

Hi Team, I am having issues loading the custom plugin at grafana path /var/lib/grafana/plugins I have used an initContainer to download the plugin from internal GitHub using PAT which works fine but can't see the plugin at Using the public helm chart here : https://github.com/grafana/helm-charts/blob/main/charts/grafana/values.yaml#L315 Any help please ?

kube-prometheus-stack-grafana-86994f6868-mpt6j:/usr/share/grafana$ ls /var/lib/grafana/plugins/
camptocamp-prometheus-alertmanager-datasource  grafana-timestream-datasource
grafana-github-datasource
    grafana:
      extraInitContainers:
        - name: plugin-init
          image: curlimages/curl:latest
          command: [ "sh", "-c" ]
          args:
            - |
              rm -rf /tmp/plugin.zip
              curl -L \
              -H "Accept: application/octet-stream" \
              -H "Authorization: Bearer xxx" \
              -H "X-GitHub-Api-Version: 2022-11-28" \
              -o /tmp/plugin.zip \
              https://api.github.com/repos/owner/repo/releases/assets/122449336
              unzip /tmp/plugin.zip -d /tmp/plugin
      extraContainerVolumes:
        - name: grafana-plugins
          emptyDir: {}
      extraVolumeMounts:
        - name: grafana-plugins
          mountPath: /var/lib/grafana/plugins
mike858585 commented 11 months ago

Hi, don't you have a problem with Duplicate value: "grafana-plugins"?

monet820 commented 7 months ago

@Jyoti492 did you get this to work, and do you have an updated example?

omri-shilton commented 6 months ago

@Jyoti492 we would also love to implement this sort of solution, got any updated working solution?

monet820 commented 6 months ago

@omri-shilton actually got this to work.

grafana:
  securityContext:
    runAsNonRoot: false
    runAsUser: 0
    runAsGroup: 472
    fsGroup: 2000

  grafana.ini:
    plugins:
      allow_loading_unsigned_plugins: pluginName

  extraInitContainers:
    - name: plugin-init
      image: quay.io/curl/curl:latest
      command: [ "sh", "-c" ]
      args:
        - |
          # Get pluginName zip
          curl -L \
          -H "Accept: application/octet-stream" \
          -H "Authorization: Bearer xxx" \
          -H "X-GitHub-Api-Version: 2022-11-28" \
          -o /tmp/pluginName.zip \
          https://api.github.com/repos/org/pluginName/releases/assets/assetIdNumber --insecure

          # Unzip pluginName where grafana read plugins
          unzip /tmp/pluginName.zip -d /var/lib/grafana/plugins

      volumeMounts:
        - name: grafana-plugins
          mountPath: /var/lib/grafana/plugins
  extraContainerVolumes:
    - name: grafana-plugins
      emptyDir: { }
  extraVolumeMounts:
    - name: grafana-plugins
      mountPath: /var/lib/grafana/plugins

If you have any chance to get the pluginName assetIdNumber in a more clean way, Id like to hear your take on that.