kube-state-metrics is a simple service that listens to the Kubernetes API server and generates metrics about the state of the objects.
kube-state-metrics exposes raw data unmodified from the Kubernetes API, this way users have all the data they require and perform heuristics as they see fit. The metrics are exported on the HTTP endpoint /metrics on the listening port (default 80). They are served as plaintext. They are designed to be consumed either by Prometheus itself or by a scraper that is compatible with scraping a Prometheus client endpoint.
Thank you to all the contributors whose hard work makes kube-state-metrics valuable for users.
Package | Version | License |
---|---|---|
kube-state-metrics | 3.8.6 | Apache 2.0 |
Click the Deploy to DigitalOcean button to install a Kubernetes 1-Click Application. If you aren’t logged in, this link will prompt you to log in with your DigitalOcean account.
In addition to creating kube-state-metrics using the control panel, you can also use the DigitalOcean API. As an example, to create a 3 node DigitalOcean Kubernetes cluster made up of Basic Droplets in the SFO2 region, you can use the following doctl
command. You need to authenticate with doctl
with your API access token) and replace the $CLUSTER_NAME
variable with the chosen name for your cluster in the command below.
doctl kubernetes clusters create --size s-4vcpu-8gb $CLUSTER_NAME --1-clicks kube-state-metrics
After you’ve successfully installed kube-state-metrics onto your cluster, you’ll be able to confirm that its running by running the following command:
kubectl get deployment kube-state-metrics -n kube-state-metrics
The output looks similar to the following:
NAME READY UP-TO-DATE AVAILABLE AGE
kube-state-metrics 1/1 1 1 6m5s
If you have Helm 3 installed, you can confirm that your deployment is healthy by running:
helm ls -n kube-state-metrics
The output looks similar to the following:
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
kube-state-metrics kube-state-metrics 1 2022-08-26 10:52:44.26049 +0300 EEST deployed kube-state-metrics-3.8.6 2.3.0
With kube-state-metrics now running on your cluster, you can view DigitalOcean Kubernetes Advanced Metrics within the DigitalOcean Kubernetes dashboard.
Insights
tab.Set kubectl
to act as a reverse proxy. This mode handles locating the API server and authenticating.
kubectl proxy --port=8080
With the proxy running you can now curl the endpoint in another terminal window:
curl http://localhost:8080/metrics
To update your installation of kube-state-metrics:
helm repo add bitnami https://charts.bitnami.com/bitnami && helm repo update
helm upgrade kube-state-metrics bitnami/kube-state-metrics --namespace kube-state
To delete your installation of kube-state-metrics:
helm uninstall kube-state-metrics --namespace kube-state-metrics