Modify the e2e local scripts so they can be run on a modern Mac
This commit is contained in:
parent
a6a77b3ec3
commit
7bf5bb0f05
|
|
@ -31,3 +31,6 @@ Session.vim
|
||||||
|
|
||||||
# Binary files
|
# Binary files
|
||||||
bin/
|
bin/
|
||||||
|
|
||||||
|
# vertical pod autoscaler test output
|
||||||
|
vertical-pod-autoscaler/e2e/v1*/workspace/
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ spec:
|
||||||
containers:
|
containers:
|
||||||
- name: admission-controller
|
- name: admission-controller
|
||||||
image: registry.k8s.io/autoscaling/vpa-admission-controller:1.2.1
|
image: registry.k8s.io/autoscaling/vpa-admission-controller:1.2.1
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: IfNotPresent
|
||||||
env:
|
env:
|
||||||
- name: NAMESPACE
|
- name: NAMESPACE
|
||||||
valueFrom:
|
valueFrom:
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ spec:
|
||||||
containers:
|
containers:
|
||||||
- name: recommender
|
- name: recommender
|
||||||
image: registry.k8s.io/autoscaling/vpa-recommender:1.2.1
|
image: registry.k8s.io/autoscaling/vpa-recommender:1.2.1
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: IfNotPresent
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpu: 200m
|
cpu: 200m
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ spec:
|
||||||
containers:
|
containers:
|
||||||
- name: updater
|
- name: updater
|
||||||
image: registry.k8s.io/autoscaling/vpa-updater:1.2.1
|
image: registry.k8s.io/autoscaling/vpa-updater:1.2.1
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: IfNotPresent
|
||||||
env:
|
env:
|
||||||
- name: NAMESPACE
|
- name: NAMESPACE
|
||||||
valueFrom:
|
valueFrom:
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,19 @@ set -o nounset
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/..
|
SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/..
|
||||||
|
BASE_NAME=$(basename $0)
|
||||||
|
source "${SCRIPT_ROOT}/hack/lib/util.sh"
|
||||||
|
|
||||||
|
ARCH=$(kube::util::host_arch)
|
||||||
|
|
||||||
function print_help {
|
function print_help {
|
||||||
echo "ERROR! Usage: deploy-for-e2e-locally.sh [suite]*"
|
echo "ERROR! Usage: $BASE_NAME [suite]*"
|
||||||
echo "<suite> should be one of:"
|
echo "<suite> should be one of:"
|
||||||
echo " - recommender"
|
echo " - recommender"
|
||||||
echo " - recommender-externalmetrics"
|
echo " - recommender-externalmetrics"
|
||||||
|
echo " - updater"
|
||||||
|
echo " - admission-controller"
|
||||||
|
echo " - full-vpa"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
|
|
@ -40,16 +47,19 @@ fi
|
||||||
SUITE=$1
|
SUITE=$1
|
||||||
|
|
||||||
case ${SUITE} in
|
case ${SUITE} in
|
||||||
recommender|recommender-externalmetrics)
|
recommender|recommender-externalmetrics|updater|admission-controller)
|
||||||
COMPONENTS="${SUITE}"
|
COMPONENTS="${SUITE}"
|
||||||
;;
|
;;
|
||||||
|
full-vpa)
|
||||||
|
COMPONENTS="recommender updater admission-controller"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
print_help
|
print_help
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Local KIND-hosted registry
|
# Local KIND images
|
||||||
export REGISTRY=${REGISTRY:-localhost:5001}
|
export REGISTRY=${REGISTRY:-localhost:5001}
|
||||||
export TAG=${TAG:-latest}
|
export TAG=${TAG:-latest}
|
||||||
|
|
||||||
|
|
@ -64,8 +74,12 @@ for i in ${COMPONENTS}; do
|
||||||
if [ $i == recommender-externalmetrics ] ; then
|
if [ $i == recommender-externalmetrics ] ; then
|
||||||
i=recommender
|
i=recommender
|
||||||
fi
|
fi
|
||||||
ALL_ARCHITECTURES=amd64 make --directory ${SCRIPT_ROOT}/pkg/${i} release REGISTRY=${REGISTRY} TAG=${TAG}
|
if [ $i == admission-controller ] ; then
|
||||||
kind load docker-image ${REGISTRY}/vpa-${i}-amd64:${TAG}
|
(cd ${SCRIPT_ROOT}/pkg/${i} && bash ./gencerts.sh e2e || true)
|
||||||
|
fi
|
||||||
|
ALL_ARCHITECTURES=${ARCH} make --directory ${SCRIPT_ROOT}/pkg/${i} docker-build REGISTRY=${REGISTRY} TAG=${TAG}
|
||||||
|
docker tag ${REGISTRY}/vpa-${i}-${ARCH}:${TAG} ${REGISTRY}/vpa-${i}:${TAG}
|
||||||
|
kind load docker-image ${REGISTRY}/vpa-${i}:${TAG}
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
# Based on https://kind.sigs.k8s.io/examples/kind-with-registry.sh
|
|
||||||
set -o errexit
|
|
||||||
|
|
||||||
# Create registry container unless it already exists
|
|
||||||
reg_name='kind-registry'
|
|
||||||
reg_port='5001'
|
|
||||||
|
|
||||||
if [ "$(docker inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)" != 'true' ]; then
|
|
||||||
docker run \
|
|
||||||
-d --restart=always -p "127.0.0.1:${reg_port}:5000" --name "${reg_name}" \
|
|
||||||
registry:2
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create a cluster with the local registry enabled in containerd
|
|
||||||
cat <<EOF | kind create cluster --image=kindest/node:v1.26.3 --config=-
|
|
||||||
kind: Cluster
|
|
||||||
apiVersion: kind.x-k8s.io/v1alpha4
|
|
||||||
containerdConfigPatches:
|
|
||||||
- |-
|
|
||||||
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:${reg_port}"]
|
|
||||||
endpoint = ["http://${reg_name}:5000"]
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Connect the registry to the cluster network if not already connected
|
|
||||||
if [ "$(docker inspect -f='{{json .NetworkSettings.Networks.kind}}' "${reg_name}")" = 'null' ]; then
|
|
||||||
docker network connect "kind" "${reg_name}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Document the local registry
|
|
||||||
# https://github.com/kubernetes/enhancements/tree/master/keps/sig-cluster-lifecycle/generic/1755-communicating-a-local-registry
|
|
||||||
cat <<EOF | kubectl apply -f -
|
|
||||||
apiVersion: v1
|
|
||||||
kind: ConfigMap
|
|
||||||
metadata:
|
|
||||||
name: local-registry-hosting
|
|
||||||
namespace: kube-public
|
|
||||||
data:
|
|
||||||
localRegistryHosting.v1: |
|
|
||||||
host: "localhost:${reg_port}"
|
|
||||||
help: "https://kind.sigs.k8s.io/docs/user/local-registry/"
|
|
||||||
EOF
|
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@ spec:
|
||||||
containers:
|
containers:
|
||||||
- name: metrics-pump
|
- name: metrics-pump
|
||||||
image: localhost:5001/write-metrics:dev
|
image: localhost:5001/write-metrics:dev
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: IfNotPresent
|
||||||
args:
|
args:
|
||||||
- /emit-metrics.py
|
- /emit-metrics.py
|
||||||
- --dest
|
- --dest
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,10 @@ spec:
|
||||||
runAsUser: 65534 # nobody
|
runAsUser: 65534 # nobody
|
||||||
containers:
|
containers:
|
||||||
- name: recommender
|
- name: recommender
|
||||||
image: localhost:5001/vpa-recommender-amd64:latest
|
image: localhost:5001/vpa-recommender:latest
|
||||||
imagePullPolicy: Never
|
imagePullPolicy: Never
|
||||||
args:
|
args:
|
||||||
- /recommender-amd64
|
- /recommender
|
||||||
- --use-external-metrics=true
|
- --use-external-metrics=true
|
||||||
- --external-metrics-cpu-metric=cpu
|
- --external-metrics-cpu-metric=cpu
|
||||||
- --external-metrics-memory-metric=mem
|
- --external-metrics-memory-metric=mem
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Copyright 2024 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.
|
||||||
|
|
||||||
|
kube::util::host_arch() {
|
||||||
|
local host_arch
|
||||||
|
case "$(uname -m)" in
|
||||||
|
x86_64*)
|
||||||
|
host_arch=amd64
|
||||||
|
;;
|
||||||
|
i?86_64*)
|
||||||
|
host_arch=amd64
|
||||||
|
;;
|
||||||
|
amd64*)
|
||||||
|
host_arch=amd64
|
||||||
|
;;
|
||||||
|
aarch64*)
|
||||||
|
host_arch=arm64
|
||||||
|
;;
|
||||||
|
arm64*)
|
||||||
|
host_arch=arm64
|
||||||
|
;;
|
||||||
|
arm*)
|
||||||
|
host_arch=arm
|
||||||
|
;;
|
||||||
|
i?86*)
|
||||||
|
host_arch=x86
|
||||||
|
;;
|
||||||
|
s390x*)
|
||||||
|
host_arch=s390x
|
||||||
|
;;
|
||||||
|
ppc64le*)
|
||||||
|
host_arch=ppc64le
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
kube::log::error "Unsupported host arch. Must be x86_64, 386, arm, arm64, s390x or ppc64le."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
echo "${host_arch}"
|
||||||
|
}
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
# Running Integration Tests locally
|
# Running Integration Tests locally
|
||||||
|
|
||||||
Included in parallel with `run-e2e.sh` and `deploy-for-e2e.sh` are two alternate versions
|
Included in parallel with `run-e2e.sh` and `deploy-for-e2e.sh` are two alternate versions
|
||||||
with `-locally` as part of their names. They use Kubernetes in Docker (`kind`) to run a local
|
with `-locally` as part of their names. They use Kubernetes in Docker (`kind`) to run a local
|
||||||
cluster in Docker. Using them will require `docker` and `kind` in your `PATH`.
|
cluster in Docker. Using them will require `docker` and `kind` in your `PATH`.
|
||||||
|
|
||||||
## External Metrics Tests
|
## External Metrics Tests
|
||||||
|
|
||||||
The external metrics tests (`recommender-externalmetrics`, available on the `-locally` variants)
|
The external metrics tests (`recommender-externalmetrics`, available on the `-locally` variants)
|
||||||
use a stack of 4 additional programs to support testing:
|
use a stack of 4 additional programs to support testing:
|
||||||
|
|
||||||
|
|
@ -29,4 +31,3 @@ The local test cases support running the `recommender` with external metrics. T
|
||||||
additional permissions we don't want to automatically enable for all customers via the
|
additional permissions we don't want to automatically enable for all customers via the
|
||||||
configuration given in `deploy/vpa-rbac.yaml`. The scripts use a context diff `hack/e2e/vpa-rbac.diff`
|
configuration given in `deploy/vpa-rbac.yaml`. The scripts use a context diff `hack/e2e/vpa-rbac.diff`
|
||||||
to enable those permission when running locally.
|
to enable those permission when running locally.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,13 +17,18 @@
|
||||||
set -o nounset
|
set -o nounset
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
|
BASE_NAME=$(basename $0)
|
||||||
SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/..
|
SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/..
|
||||||
|
|
||||||
function print_help {
|
function print_help {
|
||||||
echo "ERROR! Usage: run-e2e.sh <suite>"
|
echo "ERROR! Usage: $BASE_NAME <suite>"
|
||||||
echo "<suite> should be one of:"
|
echo "<suite> should be one of:"
|
||||||
echo " - recommender"
|
echo " - recommender"
|
||||||
echo " - recommender-externalmetrics"
|
echo " - recommender-externalmetrics"
|
||||||
|
echo " - updater"
|
||||||
|
echo " - admission-controller"
|
||||||
|
echo " - full-vpa"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
|
|
@ -38,28 +43,44 @@ fi
|
||||||
|
|
||||||
SUITE=$1
|
SUITE=$1
|
||||||
|
|
||||||
|
for i in kind docker; do
|
||||||
|
if ! command -v $i 2>&1 > /dev/null
|
||||||
|
then
|
||||||
|
echo "$i could not be found"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if ! docker ps 2>&1 >/dev/null
|
||||||
|
then
|
||||||
|
echo "docker isn't running"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo "Deleting KIND cluster 'kind'."
|
echo "Deleting KIND cluster 'kind'."
|
||||||
kind delete cluster -n kind -q
|
kind delete cluster -n kind -q
|
||||||
|
|
||||||
echo "Creating KIND cluster 'kind' with builtin registry."
|
echo "Creating KIND cluster 'kind'"
|
||||||
${SCRIPT_ROOT}/hack/e2e/kind-with-registry.sh
|
kind create cluster --image=kindest/node:v1.26.3
|
||||||
|
|
||||||
echo "Building metrics-pump image"
|
echo "Building metrics-pump image"
|
||||||
docker build -t localhost:5001/write-metrics:dev -f ${SCRIPT_ROOT}/hack/e2e/Dockerfile.externalmetrics-writer ${SCRIPT_ROOT}/hack
|
docker build -t localhost:5001/write-metrics:dev -f ${SCRIPT_ROOT}/hack/e2e/Dockerfile.externalmetrics-writer ${SCRIPT_ROOT}/hack
|
||||||
echo " pushing image to local registry"
|
echo " loading image into kind"
|
||||||
docker push localhost:5001/write-metrics:dev
|
kind load docker-image localhost:5001/write-metrics:dev
|
||||||
|
|
||||||
|
|
||||||
case ${SUITE} in
|
case ${SUITE} in
|
||||||
recommender|recommender-externalmetrics)
|
recommender|recommender-externalmetrics|updater|admission-controller|full-vpa)
|
||||||
${SCRIPT_ROOT}/hack/vpa-down.sh
|
${SCRIPT_ROOT}/hack/vpa-down.sh
|
||||||
echo " ** Deploying for suite ${SUITE}"
|
echo " ** Deploying for suite ${SUITE}"
|
||||||
${SCRIPT_ROOT}/hack/deploy-for-e2e-locally.sh ${SUITE}
|
${SCRIPT_ROOT}/hack/deploy-for-e2e-locally.sh ${SUITE}
|
||||||
|
|
||||||
echo " ** Running suite ${SUITE}"
|
echo " ** Running suite ${SUITE}"
|
||||||
if [ ${SUITE} == recommender-externalmetrics ]; then
|
if [ ${SUITE} == recommender-externalmetrics ]; then
|
||||||
${SCRIPT_ROOT}/hack/run-e2e-tests.sh recommender
|
WORKSPACE=./workspace/_artifacts ${SCRIPT_ROOT}/hack/run-e2e-tests.sh recommender
|
||||||
else
|
else
|
||||||
${SCRIPT_ROOT}/hack/run-e2e-tests.sh ${SUITE}
|
WORKSPACE=./workspace/_artifacts ${SCRIPT_ROOT}/hack/run-e2e-tests.sh ${SUITE}
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
|
||||||
|
|
@ -44,13 +44,15 @@ SUITE=$1
|
||||||
|
|
||||||
export GO111MODULE=on
|
export GO111MODULE=on
|
||||||
|
|
||||||
|
export WORKSPACE=${WORKSPACE:-/workspace/_artifacts}
|
||||||
|
|
||||||
case ${SUITE} in
|
case ${SUITE} in
|
||||||
recommender|updater|admission-controller|actuation|full-vpa)
|
recommender|updater|admission-controller|actuation|full-vpa)
|
||||||
export KUBECONFIG=$HOME/.kube/config
|
export KUBECONFIG=$HOME/.kube/config
|
||||||
pushd ${SCRIPT_ROOT}/e2e
|
pushd ${SCRIPT_ROOT}/e2e
|
||||||
go test -mod vendor ./v1beta2/*go -v --test.timeout=90m --args --ginkgo.v=true --ginkgo.focus="\[VPA\] \[${SUITE}\]" --report-dir=/workspace/_artifacts --disable-log-dump --ginkgo.timeout=90m
|
go test -mod vendor ./v1beta2/*go -v --test.timeout=90m --args --ginkgo.v=true --ginkgo.focus="\[VPA\] \[${SUITE}\]" --report-dir=${WORKSPACE} --disable-log-dump --ginkgo.timeout=90m
|
||||||
V1BETA2_RESULT=$?
|
V1BETA2_RESULT=$?
|
||||||
go test -mod vendor ./v1/*go -v --test.timeout=90m --args --ginkgo.v=true --ginkgo.focus="\[VPA\] \[${SUITE}\]" --report-dir=/workspace/_artifacts --disable-log-dump --ginkgo.timeout=90m
|
go test -mod vendor ./v1/*go -v --test.timeout=90m --args --ginkgo.v=true --ginkgo.focus="\[VPA\] \[${SUITE}\]" --report-dir=${WORKSPACE} --disable-log-dump --ginkgo.timeout=90m
|
||||||
V1_RESULT=$?
|
V1_RESULT=$?
|
||||||
popd
|
popd
|
||||||
echo v1beta2 test result: ${V1BETA2_RESULT}
|
echo v1beta2 test result: ${V1BETA2_RESULT}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue