headlamp-k8s / headlamp

A Kubernetes web UI that is fully-featured, user-friendly and extensible
https://headlamp.dev
Apache License 2.0
2.22k stars 156 forks source link

Prometheus plugin not shown for inCluster deployment #1800

Closed SquupS closed 6 months ago

SquupS commented 7 months ago

I have build and shipped the prometheus plugin to the 0.23.0 inCluster Deployment of headlamp.

However, the plugin is not shown under settings/plugins, nor do I see the switch to turn it on.

The plugin folder is propperly placed in /headlamp/plugins/ which is also the source for the -plugin-dir flag.

Any hints what I have missed?

joaquimrocha commented 7 months ago

@SquupS , Indeed that seems like a problem in reading the plugin from its source location. Are you passing the main.js + package.json file of that plugin, or just the main.js? Both are needed so Headlamp knows whether the plugin is compatible. If you are passing both files, can you share more details about your Headlamp deployment?

@yolossn , can you follow up with @SquupS 's replies? Maybe we should also update this post just with a quick note that the package.json needs to be included as well (no need to modify the whole post/screenshots, just an Update: notice where needed) https://headlamp.dev/blog/2022/10/get-up-to-speed-deploying-headlamp-with-plugins/

SquupS commented 7 months ago

@joaquimrocha @yolossn yes, both files are provided within the folder

image

Besides that, it is just a pretty default deployment with the following args and envs

      args:
        - '-in-cluster'
        - '-insecure-ssl'
        - '-base-url=/headlamp'
        - '-plugins-dir=/headlamp/plugins/'

      env:
        - name: HEADLAMP_CONFIG_BASE_URL
          value: /headlamp
yolossn commented 7 months ago

@SquupS Can you share the response that you get when accessing <YOUR-HEADLAMP-URL>/headlamp/plugins?

SquupS commented 7 months ago

Sure @yolossn

[ "/headlamp/static-plugins/prometheus", "/headlamp/plugins/headlamp-plugins" ]

yolossn commented 7 months ago

Looks like you have two instances of Prometheus plugin loaded. One from the static plugins and the other that is added by you.Do you see any errors in the console log?

SquupS commented 7 months ago

There are some, yes @yolossn

image

Is this static one some automatically added plugin? Because if this gets ship per default, I would not have added one manually :-) But also without adding the plugin unter /headlamp/plugins I got no prometheus button/charts shown

yolossn commented 7 months ago

@SquupS Yes the static plugins are the ones that are preinstalled with headlamp and we do ship the Prometheus plugin by default with headlamp. I checked if the Prometheus plugin is working properly with our latest version and it is working as expected. Can you try installing the latest version of headlamp and check if it is working for you.

SquupS commented 7 months ago

Sure I can redeploy @yolossn But I was already using the latest 0.23.0 Version.

SquupS commented 7 months ago

@yolossn redeployed and removed my added plugin, so that only the static one is left. I receive the same errors like shown before and no button is shown for metrics.

Are there maybe any uncommented preconditions in order for that button to appear? I also compared my helm Chart to the one you provide here and those are more or less identical

yolossn commented 7 months ago

Thanks for the update, Can you expand the errors that you see in the console and share it?

SquupS commented 7 months ago

@yolossn hope that suits your needs?

image

yolossn commented 7 months ago

@SquupS After a couple of attempts I am able to reproduce this error. Apparently it is occurring due to the "-base-url" argument, It works properly when the -base-url argument isn't set. I will work on a fix for this.

SquupS commented 7 months ago

@yolossn that sounds awesome. Looking foward to the fix. Thanks a lot for the investigation.

yolossn commented 6 months ago

@SquupS Could you please test the custom container build with the fix I created and pushed to ttl.sh/headlamp-base-path-fix:latest? This is to verify if the solution resolves the issue with using the Prometheus plugin correctly. Thanks!

SquupS commented 6 months ago

@yolossn Can confirm, that the metrics button is now showing up per default, without having to run an init container or such.