Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add recommender vpa-object-namespace quick integration test #7769

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/bash

# Copyright 2025 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})/../../../..

export REGISTRY=${REGISTRY:-localhost:5001}
export TAG=${TAG:-latest}


REGISTRY=${REGISTRY} TAG=${TAG} ${SCRIPT_ROOT}/hack/vpa-process-yaml.sh ${SCRIPT_ROOT}/hack/integration-tests/deploy/recommender/ignored-vpa-object-namespaces.yaml | kubectl apply -f -

CHECK_CYCLES=15
CHECK_SLEEP=15

if kubectl wait --for=condition=Available --timeout=120s deployment/vpa-recommender -n kube-system; then
echo "Verified vpa-recommender pod was scheduled and started!"
else
echo "vpa-recommender pod did not start within the expected time."
exit 1
fi

EXIT_STATUS=2
for i in $(seq 1 $CHECK_CYCLES); do
if kubectl describe vpa -n included-namespace included-vpa | grep Status; then
echo "Verified included namespaces are being tracked!"
EXIT_STATUS=0
break
fi
echo "Assertion Loop $i/$CHECK_CYCLES, sleeping for $CHECK_SLEEP seconds"
sleep $CHECK_SLEEP
done

if [[ $EXIT_STATUS -ne 0 ]];then
exit $EXIT_STATUS
fi

CHECK_CYCLES=5

for i in $(seq 1 $CHECK_CYCLES); do
if kubectl describe vpa -n ignored-namespace ignored-vpa | grep Status; then
echo "Failed! ignored namespaces should not be tracked!"
EXIT_STATUS=3
break
fi
echo "Assertion Loop $i/$CHECK_CYCLES, sleeping for $CHECK_SLEEP seconds"
sleep $CHECK_SLEEP
done

if [[ $EXIT_STATUS -ne 0 ]];then
exit $EXIT_STATUS
fi

echo "Verified ignored namespaces are still not tracked after wait time!"

REGISTRY=${REGISTRY} TAG=${TAG} ${SCRIPT_ROOT}/hack/vpa-process-yaml.sh ${SCRIPT_ROOT}/hack/integration-tests/deploy/recommender/ignored-vpa-object-namespaces.yaml | kubectl delete -f -
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: vpa-recommender
namespace: kube-system
spec:
replicas: 1
selector:
matchLabels:
app: vpa-recommender
template:
metadata:
labels:
app: vpa-recommender
spec:
serviceAccountName: vpa-recommender
securityContext:
runAsNonRoot: true
runAsUser: 65534 # nobody
containers:
- name: recommender
image: registry.k8s.io/autoscaling/vpa-recommender:1.2.2
imagePullPolicy: IfNotPresent
args:
- /recommender
- --ignored-vpa-object-namespaces=ignored-namespace
resources:
limits:
cpu: 200m
memory: 1000Mi
requests:
cpu: 50m
memory: 500Mi
ports:
- name: prometheus
containerPort: 8942
---
apiVersion: v1
kind: Namespace
metadata:
name: included-namespace
---
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
name: included-vpa
namespace: included-namespace
spec:
targetRef:
apiVersion: "apps/v1"
kind: Deployment
name: included-app
updatePolicy:
updateMode: "Auto"
---
apiVersion: v1
kind: Namespace
metadata:
name: ignored-namespace
---
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
name: ignored-vpa
namespace: ignored-namespace
spec:
targetRef:
apiVersion: "apps/v1"
kind: Deployment
name: ignored-app
updatePolicy:
updateMode: "Auto"
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/bash

# Copyright 2025 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})/../../../..

export REGISTRY=${REGISTRY:-localhost:5001}
export TAG=${TAG:-latest}


REGISTRY=${REGISTRY} TAG=${TAG} ${SCRIPT_ROOT}/hack/vpa-process-yaml.sh ${SCRIPT_ROOT}/hack/integration-tests/deploy/recommender/vpa-object-namespace.yaml | kubectl apply -f -

CHECK_CYCLES=15
CHECK_SLEEP=15

if kubectl wait --for=condition=Available --timeout=120s deployment/vpa-recommender -n kube-system; then
echo "Verified vpa-recommender pod was scheduled and started!"
else
echo "vpa-recommender pod did not start within the expected time."
exit 1
fi

EXIT_STATUS=2
for i in $(seq 1 $CHECK_CYCLES); do
if kubectl describe vpa -n included-namespace included-vpa | grep Status; then
echo "Verified included namespaces are being tracked!"
EXIT_STATUS=0
break
fi
echo "Assertion Loop $i/$CHECK_CYCLES, sleeping for $CHECK_SLEEP seconds"
sleep $CHECK_SLEEP
done

if [[ $EXIT_STATUS -ne 0 ]];then
exit $EXIT_STATUS
fi

CHECK_CYCLES=5

for i in $(seq 1 $CHECK_CYCLES); do
if kubectl describe vpa -n ignored-namespace ignored-vpa | grep Status; then
echo "Failed! ignored namespaces should not be tracked!"
EXIT_STATUS=3
break
fi
echo "Assertion Loop $i/$CHECK_CYCLES, sleeping for $CHECK_SLEEP seconds"
sleep $CHECK_SLEEP
done

if [[ $EXIT_STATUS -ne 0 ]];then
exit $EXIT_STATUS
fi

echo "Verified ignored namespaces are still not tracked after wait time!"

REGISTRY=${REGISTRY} TAG=${TAG} ${SCRIPT_ROOT}/hack/vpa-process-yaml.sh ${SCRIPT_ROOT}/hack/integration-tests/deploy/recommender/vpa-object-namespace.yaml | kubectl delete -f -
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: vpa-recommender
namespace: kube-system
spec:
replicas: 1
selector:
matchLabels:
app: vpa-recommender
template:
metadata:
labels:
app: vpa-recommender
spec:
serviceAccountName: vpa-recommender
securityContext:
runAsNonRoot: true
runAsUser: 65534 # nobody
containers:
- name: recommender
image: registry.k8s.io/autoscaling/vpa-recommender:1.2.2
imagePullPolicy: IfNotPresent
args:
- /recommender
- --vpa-object-namespace=included-namespace
resources:
limits:
cpu: 200m
memory: 1000Mi
requests:
cpu: 50m
memory: 500Mi
ports:
- name: prometheus
containerPort: 8942
---
apiVersion: v1
kind: Namespace
metadata:
name: included-namespace
---
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
name: included-vpa
namespace: included-namespace
spec:
targetRef:
apiVersion: "apps/v1"
kind: Deployment
name: included-app
updatePolicy:
updateMode: "Auto"
---
apiVersion: v1
kind: Namespace
metadata:
name: ignored-namespace
---
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
name: ignored-vpa
namespace: ignored-namespace
spec:
targetRef:
apiVersion: "apps/v1"
kind: Deployment
name: ignored-app
updatePolicy:
updateMode: "Auto"
Loading
Loading