k8s-kubecost-exporter

command module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2023 License: MIT Imports: 17 Imported by: 0

README

K8s Kubecost Exporter

MIT License Maintained by Infrable

k8s-kubecost-exporter is a Kubernetes application that exposes cost allocation metrics retrieved from Kubecost.

Cost allocation metrics are retrieved from the Kubecost Allocation API and made available via a metrics HTTP endpoint (/metrics). Applications that can extract custom metrics from OpenMetrics endpoints (Prometheus, Datadog, New Relic etc.) can be configured to scrape this endpoint.

For an architecture overview of Kubecost, see the following documentation:

Development

k8s-kubecost-exporter works in conjunction with Kubecost.

For deploying k8s-kubecost-exporter locally via Minikube, see the following documentation:

For deploying Kubecost locally via Minikube, see the following documentation:

Optionally, you can install New Relic's infrastructure monitoring agent via Helm using the following documentation:

See the Standard Go Project Layout GitHub repository for a canonical layout of Go applications upon which this repository is based.

The official container image (Dockerfile) contains only the binary executable, so for debugging purposes, a Dockerfile (Dockerfile.debug), is provided based on Alpine Linux.

Unit Testing

Unit testing is facilitate by gomock, a mocking framework for Go.

Mocked interfaces are generated using the following command:

$ mockgen -package main -source client.go -destination client_mock.go

Testing

To test the Go code, run the following:

$ go test

To test the Helm chart, run the following:

$ helm lint deploy/helm/kubecost-exporter
$ helm package deploy/helm/kubecost-exporter
$ kubectl create namespace kubecost-exporter
$ helm install kubecost-exporter kubecost-exporter-<version>.tgz --namespace kubecost-exporter \
  --set image.registry="" \
  --set image.repository="kubecost-exporter" \
  --set image.tag="latest" \
  --wait
$ helm test kubecost-exporter --namespace kubecost-exporter

NOTE: The container image can be built locally and made available to Minikube by running the following:

$ eval $(minikube -p minikube docker-env)
$ docker build -t kubecost-exporter:latest .

Documentation

Overview

An HTTP client for interacting with the Kubecost Allocation API.

For documentation on the Go standard library net/http package, see the following:

For documentation on the Kubecost Allocation API, see the following:

Package main is a generated GoMock package.

Application configuration.

For documentation on Viper, see the following:

An HTTP server for exposing cost allocation metrics retrieved from Kubecost.

Metrics are exposed via an HTTP metrics endpoint. Applications that provide a Prometheus OpenMetrics integration can gather cost allocation metrics from this endpoint to store and visualize the data.

Generate Prometheus metrics from configuration.

For documentation on the Go client library for Prometheus, see the following:

Utility functions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL