Prior to this fix, openapi spec for prometheus-adapter apiextension was based on the type "k8s.io/sample-apiserver/pkg/apiserver" which is incorrect. Due to the incorrect type, `kubectl explain podmetrics` (or nodemetrics) wasn't showing any doc for any resources from metrics.k8s.io/v1beta1.
This changeset fixes the problem by using the right type(sigs.k8s.io/metrics-server/pkg/api) for the openapi generation.
This also helped to remove the sample-apiserver dependency from
prometheus-adapter.
Signed-off-by: Arunprasad Rajkumar <arajkuma@redhat.com>
When serving the resource metrics API, prometheus-adapter may return
negative values for pods/nodes memory and CPU usage. This happens
because Prometheus sees counter resets which results in Prometheus
interpolating data incorrectly to avoid the counter value going down.
To prevent that, we need to add some guards in prometheus-adapter to
replace the negative value by zero whenever it detects one.
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
The IMAGE env variable is used by prow when building images, so it was
replacing what we would have expected to be the `prometheus-adapter`
image by the container image used to build the prometheus-adapter image.
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
Improve and cleanup container push rules to prepare for the move to the
official gcr.k8s.io registry.
As part of the improvements, I replaced the non cross platform busybox
image by gcr.io/distroless/static:latest which is platform agnostic.
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
The latest version of metrics-server, v0.5.0 doesn't seem to require
having kubelet dependencies locally anymore. Thus, we can safely remove
the localvendor directory that was used to store them.
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
As part of this commit, I upgraded the golang image used for building to
1.16 and consolidated how the docker-build rule was working. Previously,
it was failing in master's CI because the go modules were not downloaded
in the build image. To improve that, I replaced the combination of
docker run and docker build by a multi-stage Dockerfile responsible for
building the adapter and running it.
In addition to that, I removed the `_output` directory completely as it
wasn't really meaningful to have it anymore. I also removed the
`build-local-image` rule as it was a duplicate of the `docker-build`
rule with the only different of using a scratch base image.
Also, since all the base images that we are using by default are based
on busybox, I change the UID used in the image to 65534 which correspond
to the nobody user in busybox.
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
Create the pod lister based on a filtered informer factory that will
filter non-running pods so that prometheus-adapter don't expect metrics
from them.
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
The code that we are reusing from metrics-server to call
GetContainerMetrics and GetNodeMetrics requires that both functions
returns arrays of lengths of the number of pods/nodes given as
arguments. In some cases, prometheus-adapter was returning nil which
caused panics in metrics-server code.
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>