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>
Add a signal handler stopping the adapter if it receives a SIGINT or
SIGTERM signal. This prevent the prometheus-adapter pod from being stuck
in "Terminating" state.
Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>