eslam-gomaa / kptop

A Python tool that offers beautiful CLI monitoring based on Prometheus metrics, with Kubernetes integration through PodPortForward
https://eslam-gomaa.github.io/kptop/
GNU General Public License v3.0
277 stars 11 forks source link

fix basic auth support for validation checks and queries #14

Closed sakserv closed 1 year ago

sakserv commented 1 year ago

Thanks for the tool, it looks promising! Opening PRs for issues I hit. Here is one that allows the validation checks to pass when basic auth is required.

The first POST call to the healthy endpoint results in a Method Not Allowed. It should be a GET, even with basic auth enabled. The rest of the changes add the same conditional check and auth headers.

With these changes, validation passes in my testing:

# python3 kptop_tool.py -V

Verifying Prometheus connection: Connected
{
  "connected": true,
  "status_code": 200,
  "reason": "",
  "fail_reason": ""
}

Verifying Prometheus Exporters:

* Node Exporter:  Found
{
  "success": true,
  "fail_reason": "",
  "result": {
    "found_versions": {
      "1.3.1": "53"
    }
  }
}

* Kubernetes Exporter:  Found
{
  "success": true,
  "fail_reason": "",
  "result": {
    "found_git_versions": {
      "v1.23.5: "62"
    }
  }
}