diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..558bcee --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +bin/ +coverage.out + diff --git a/README.md b/README.md index 9d2c48d..857780f 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Running locally: 1. Docker Desktop (with kubernetes) 2. skaffold https://skaffold.dev/docs/install/ -3. `skaffold dev` +3. `skaffold dev -p local` 4. `kubectl -n kubelet-summary-exporter port-forward ds/kubelet-summary-exporter 9091` 5. `curl localhost:9091/metrics` diff --git a/pkg/scraper/scraper.go b/pkg/scraper/scraper.go index d2ac7ee..7cc5080 100644 --- a/pkg/scraper/scraper.go +++ b/pkg/scraper/scraper.go @@ -73,7 +73,7 @@ func (s *Scraper) Collect(ch chan<- prometheus.Metric) { if err != nil { s.errCnt++ ch <- prometheus.MustNewConstMetric( - s.storage, + s.errors, prometheus.CounterValue, s.errCnt, "request error", @@ -85,7 +85,7 @@ func (s *Scraper) Collect(ch chan<- prometheus.Metric) { if resp.StatusCode != http.StatusOK { s.errCnt++ ch <- prometheus.MustNewConstMetric( - s.storage, + s.errors, prometheus.CounterValue, s.errCnt, "status error", @@ -99,7 +99,7 @@ func (s *Scraper) Collect(ch chan<- prometheus.Metric) { if err != nil { s.errCnt++ ch <- prometheus.MustNewConstMetric( - s.storage, + s.errors, prometheus.CounterValue, s.errCnt, "read body error", @@ -111,7 +111,7 @@ func (s *Scraper) Collect(ch chan<- prometheus.Metric) { summary, err := s.parse(body) if err != nil { ch <- prometheus.MustNewConstMetric( - s.storage, + s.errors, prometheus.CounterValue, s.errCnt, "parse body error", diff --git a/pkg/scraper/scraper_test.go b/pkg/scraper/scraper_test.go index d19f330..75e812e 100644 --- a/pkg/scraper/scraper_test.go +++ b/pkg/scraper/scraper_test.go @@ -71,7 +71,6 @@ func TestDecodingJson(t *testing.T) { if diff := cmp.Diff(tc.WantSummary, summary); diff != "" { t.Errorf("summary mismatch (-want +got):\n%s", diff) } - }) } } diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index a231df9..bac56c8 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -5,9 +5,9 @@ import ( "crypto/tls" "crypto/x509" "fmt" - "io/ioutil" "net" "net/http" + "os" "time" "go.uber.org/zap" @@ -19,7 +19,7 @@ import ( func ConfigureTLS(logger *zap.Logger, certAuthorityFile string, insecure bool, nodeHost string) error { // Set the root CA pool - cadata, err := ioutil.ReadFile(certAuthorityFile) + cadata, err := os.ReadFile(certAuthorityFile) if err != nil { return err } diff --git a/skaffold.yaml b/skaffold.yaml index 2907697..f5e1944 100644 --- a/skaffold.yaml +++ b/skaffold.yaml @@ -1,14 +1,19 @@ -apiVersion: skaffold/v2beta19 +apiVersion: skaffold/v4beta6 kind: Config +metadata: + name: kubelet-summary-exporter build: artifacts: - - image: kubelet-summary-exporter/exporter - context: ./ - docker: - dockerfile: Dockerfile - tagPolicy: - inputDigest: {} -deploy: + - image: kubelet-summary-exporter/exporter + docker: + dockerfile: Dockerfile +manifests: kustomize: paths: - - config/local + - config/base +profiles: + - name: local + manifests: + kustomize: + paths: + - config/local