This repository contains boilerplate code for setting up an implementation of the custom metrics API (https://github.com/kubernetes/metrics).
It includes the necessary boilerplate for setting up an implementation (generic API server setup, registration of resources, etc), plus a sample implementation backed by fake data.
This repository is designed to be used as a library. First, implement one
or more of the metrics provider interfaces in pkg/provider
(for example,
CustomMetricsProvider
), depending on which APIs you want to support.
Then, use the AdapterBase
in pkg/cmd
to initialize the necessary flags
and set up the API server, passing in your providers.
More information can be found in the getting started guide, and a sample implementation can be found in the sample directory.
It is strongly suggested that you make use of the dependency versions listed in glide.yaml, as mismatched versions of Kubernetes dependencies can lead to build issues.
- glide to install dependencies before you can use this project.
- Go same version of Go as Kubernetes
- Mercurial - one of dependencies requires hg
- git
There is a sample adapter in this repository that can be used for testing changes to the repository, and also acts as an example implementations.
To build and deploy it:
# build the sample container as $REGISTRY/k8s-custom-metric-adapter-sample
export REGISTRY=<some-prefix>
make sample-container
# push the container up to a registry (optional if your cluster is local)
docker push $REGISTRY/k8s-custom-metric-adapter-sample
# launch the adapter using the sample deployment files
kubectl create namespace custom-metrics
kubectl apply -f sample-deploy/manifests
After the deployment you can query the sample adapter with:
# you can pipe to `jq .` to pretty-print the output, if it's installed
kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1"
The APIs in this repository follow the standard guarantees for Kubernetes APIs, and will follow Kubernetes releases.
Learn how to engage with the Kubernetes community on the community page.
You can reach the maintainers of this repository at:
- Slack: #sig-instrumentation (on https://kubernetes.slack.com -- get an invite at slack.kubernetes.io)
- Mailing List: https://groups.google.com/forum/#!forum/kubernetes-sig-instrumentation
Participation in the Kubernetes community is governed by the Kubernetes Code of Conduct.
See CONTRIBUTING.md for more information.