Fix prometheus cadvisor authentication (#9497)
This commit is contained in:
parent
2eb0ee2e1e
commit
8965291f29
|
|
@ -88,7 +88,7 @@ func (p *Prometheus) start(ctx context.Context) error {
|
||||||
return
|
return
|
||||||
case <-time.After(time.Second):
|
case <-time.After(time.Second):
|
||||||
if p.isNodeScrapeScope {
|
if p.isNodeScrapeScope {
|
||||||
err = p.cAdvisor(ctx)
|
err = p.cAdvisor(ctx, config.BearerToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.Log.Errorf("Unable to monitor pods with node scrape scope: %s", err.Error())
|
p.Log.Errorf("Unable to monitor pods with node scrape scope: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
@ -145,10 +145,13 @@ func (p *Prometheus) watchPod(ctx context.Context, client *kubernetes.Clientset)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Prometheus) cAdvisor(ctx context.Context) error {
|
func (p *Prometheus) cAdvisor(ctx context.Context, bearerToken string) error {
|
||||||
// The request will be the same each time
|
// The request will be the same each time
|
||||||
podsURL := fmt.Sprintf("https://%s:10250/pods", p.NodeIP)
|
podsURL := fmt.Sprintf("https://%s:10250/pods", p.NodeIP)
|
||||||
req, err := http.NewRequest("GET", podsURL, nil)
|
req, err := http.NewRequest("GET", podsURL, nil)
|
||||||
|
req.Header.Set("Authorization", "Bearer "+bearerToken)
|
||||||
|
req.Header.Add("Accept", "application/json")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error when creating request to %s to get pod list: %w", podsURL, err)
|
return fmt.Errorf("error when creating request to %s to get pod list: %w", podsURL, err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue