Skip to content

Commit

Permalink
External Metrics w/E2E testing, prometheus, & KIND.
Browse files Browse the repository at this point in the history
  • Loading branch information
lallydd committed Jul 6, 2023
1 parent b569db4 commit 68c9db8
Show file tree
Hide file tree
Showing 39 changed files with 3,082 additions and 35 deletions.
1 change: 1 addition & 0 deletions vertical-pod-autoscaler/e2e/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDD
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153 h1:yUdfgN0XgIJw7foRItutHYUIhlcKzcSf5vDpdhQAKTc=
github.com/emicklei/go-restful/v3 v3.5.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
github.com/emicklei/go-restful/v3 v3.10.1 h1:rc42Y5YTp7Am7CS630D7JmhRjq4UlEUuEKfrDac4bSQ=
github.com/emicklei/go-restful/v3 v3.10.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

86 changes: 86 additions & 0 deletions vertical-pod-autoscaler/hack/deploy-for-e2e-locally.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/bin/bash

# Copyright 2023 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail

SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/..

function print_help {
echo "ERROR! Usage: deploy-for-e2e-locally.sh [suite]*"
echo "<suite> should be one of:"
echo " - recommender"
echo " - recommender-externalmetrics"
echo "If component is not specified all above will be started."
}

if [ $# -eq 0 ]; then
print_help
exit 1
fi

if [ $# -gt 1 ]; then
print_help
exit 1
fi

SUITE=$1

case ${SUITE} in
recommender|recommender-externalmetrics)
COMPONENTS="${SUITE}"
;;
*)
print_help
exit 1
;;
esac

# Local KIND-hosted registry
export REGISTRY=localhost:5001
export TAG=latest

rm -f ${SCRIPT_ROOT}/hack/e2e/vpa-rbac.yaml
patch -c ${SCRIPT_ROOT}/deploy/vpa-rbac.yaml -i ${SCRIPT_ROOT}/hack/e2e/vpa-rbac.diff -o ${SCRIPT_ROOT}/hack/e2e/vpa-rbac.yaml
kubectl apply -f ${SCRIPT_ROOT}/hack/e2e/vpa-rbac.yaml
# Other-versioned CRDs are irrelevant as we're running a modern-ish cluster.
kubectl apply -f ${SCRIPT_ROOT}/deploy/vpa-v1-crd-gen.yaml
kubectl apply -f ${SCRIPT_ROOT}/hack/e2e/k8s-metrics-server.yaml

for i in ${COMPONENTS}; do
if [ $i == admission-controller ] ; then
(cd ${SCRIPT_ROOT}/pkg/${i} && bash ./gencerts.sh || true)
elif [ $i == recommender-externalmetrics ] ; then
i=recommender
fi
ALL_ARCHITECTURES=amd64 make --directory ${SCRIPT_ROOT}/pkg/${i} release REGISTRY=${REGISTRY} TAG=${TAG}
kind load docker-image ${REGISTRY}/vpa-${i}-amd64:${TAG}
done


for i in ${COMPONENTS}; do
if [ $i == recommender-externalmetrics ] ; then
kubectl delete namespace monitoring --ignore-not-found=true
kubectl create namespace monitoring
kubectl apply -f ${SCRIPT_ROOT}/hack/e2e/prometheus.yaml
kubectl apply -f ${SCRIPT_ROOT}/hack/e2e/prometheus-adapter.yaml
kubectl apply -f ${SCRIPT_ROOT}/hack/e2e/metrics-pump.yaml
kubectl apply -f ${SCRIPT_ROOT}/hack/e2e/${i}-deployment.yaml
else
REGISTRY=${REGISTRY} TAG=${TAG} ${SCRIPT_ROOT}/hack/vpa-process-yaml.sh ${SCRIPT_ROOT}/deploy/${i}-deployment.yaml | kubectl apply -f -
fi
done
18 changes: 18 additions & 0 deletions vertical-pod-autoscaler/hack/e2e/Dockerfile.externalmetrics-writer
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2023 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM python:3.10-slim
RUN pip3 install kubernetes argparse requests

COPY emit-metrics.py /
Loading

0 comments on commit 68c9db8

Please sign in to comment.