diff options
Diffstat (limited to 'src/go/collectors/go.d.plugin/modules/k8s_kubelet/init.go')
-rw-r--r-- | src/go/collectors/go.d.plugin/modules/k8s_kubelet/init.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/go/collectors/go.d.plugin/modules/k8s_kubelet/init.go b/src/go/collectors/go.d.plugin/modules/k8s_kubelet/init.go new file mode 100644 index 000000000..3a076160b --- /dev/null +++ b/src/go/collectors/go.d.plugin/modules/k8s_kubelet/init.go @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +package k8s_kubelet + +import ( + "errors" + "os" + + "github.com/netdata/netdata/go/go.d.plugin/pkg/prometheus" + "github.com/netdata/netdata/go/go.d.plugin/pkg/web" +) + +func (k *Kubelet) validateConfig() error { + if k.URL == "" { + return errors.New("url not set") + } + return nil +} + +func (k *Kubelet) initAuthToken() string { + bs, err := os.ReadFile(k.TokenPath) + if err != nil { + k.Warningf("error on reading service account token from '%s': %v", k.TokenPath, err) + } + return string(bs) +} + +func (k *Kubelet) initPrometheusClient() (prometheus.Prometheus, error) { + httpClient, err := web.NewHTTPClient(k.Client) + if err != nil { + return nil, err + } + + return prometheus.New(httpClient, k.Request), nil +} |