Skip to content
Metrics Server Exporter
Python Dockerfile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
deploy
CONTRIBUTING.md
Dockerfile
LICENSE.md
README.md
app.py
requirements.txt

README.md

metrics-server-exporter CircleCI

metrics-server-exporter provides cpu and memory metrics for nodes and pods, directly querying the metrics-server API /apis/metrics.k8s.io/v1beta1/{pods, nodes}

Node metrics

  • kube_metrics_server_nodes_mem
    • Provides nodes memory information in kibibytes.
  • kube_metrics_server_nodes_cpu
    • Provides nodes CPU information in nanocores.
labels
  • instance

Pod metrics

  • kube_metrics_server_pods_mem
    • Provides pods/container memory information.
  • kube_metrics_server_pods_cpu
    • Provides pods/container memory information.
labels
  • pod_name
  • pod_namespace
  • pod_container_name

API metrics

  • kube_metrics_server_response_time
    • Provides API response time in seconds.

Variables

  • K8S_ENDPOINT

    • Url of API of kubernetes (default kubernetes.default.svc)
  • K8S_TOKEN

    • The authorization token (default ServiceAccount token)
  • K8S_FILEPATH_TOKEN

    • Path of ServiceAccount token file (default /var/run/secrets/kubernetes.io/serviceaccount/token)
  • K8S_CA_CERT_PATH

    • Path of Kubernetes CA certificate (default /var/run/secrets/kubernetes.io/serviceaccount/ca.crt)
  • NAMES_BLACKLIST

    • A list of names from pods, containers or namespaces to exclude from metrics.

Options

  • --insecure-tls
    • Disables TLS verification of the Kubernetes API Server. (Not recommended in production)

How to build

$ docker build . -t vivareal/metrics-server-exporter

How to run

You will need K8S_TOKEN and K8S_ENDPOINT to access the api-server. Use "--insecure-tls" or mount the CA certificate into the container. Kubernetes will provide the CA certificate in a Kubernetes installation.

$ docker run -p 8000:8000 -e "K8S_ENDPOINT=${K8S_ENDPOINT}" -e "K8S_TOKEN=${K8S_TOKEN}" vivareal/metrics-server-exporter --insecure-tls

How to deploy

Set you target k8s context and apply the deployment files

$ kubectl apply -f deploy/

Blacklist

If you want, you could blacklist some names of namespaces, pods or containers, you just need to apply this ConfigMap, replacing the example names

apiVersion: v1
kind: ConfigMap
metadata:
  name: metrics-server-exporter
  labels:
    k8s-app: metrics-server-exporter
data:
  NAMES_BLACKLIST: kube-proxy,calico-node,kube2iam # example names

Minikube

How to test in Minikube

$ minikube delete; minikube start --vm-driver=kvm2 --cpus=2 --memory=4096
* Deleting "minikube" from kvm2 ...
* The "minikube" cluster has been deleted.
* minikube v1.2.0 on linux (amd64)
* Creating kvm2 VM (CPUs=2, Memory=4096MB, Disk=20000MB) ...
* Configuring environment for Kubernetes v1.15.0 on Docker 18.09.6
* Downloading kubelet v1.15.0
* Downloading kubeadm v1.15.0
* Pulling images ...
* Launching Kubernetes ...
* Verifying: apiserver proxy etcd scheduler controller dns
* Done! kubectl is now configured to use "minikube"

Enable metrics-server addon

$ minikube addons enable metrics-server
* metrics-server was successfully enabled

Deploy the files in minikube

$ kubectl apply -R -f deploy/

Then, test the connectivity

$ kubectl port-forward -n kube-system svc/metrics-server-exporter 9104:9104 &
$ curl http://localhost:9104/metrics
You can’t perform that action at this time.