Skip to content

Commit 0b6f2d6

Browse files
committed
VPA: Allow deploying InPlaceOrRecreate in local e2e and ci
Allows you to specify an env var FEATURE_GATES which adds feature gates to all vpa components during vpa-up and e2e tests. Also allows local e2e tests to run kind with a new kind-config file which enables KEP-1287 InPlacePodVerticalScaling feature gate. Separates the admission-controller service into a separate deploy manifest. Signed-off-by: Max Cao <[email protected]>
1 parent de4a5b7 commit 0b6f2d6

File tree

9 files changed

+47
-18
lines changed

9 files changed

+47
-18
lines changed

vertical-pod-autoscaler/deploy/admission-controller-deployment.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,3 @@ spec:
4747
- name: tls-certs
4848
secret:
4949
secretName: vpa-tls-certs
50-
---
51-
apiVersion: v1
52-
kind: Service
53-
metadata:
54-
name: vpa-webhook
55-
namespace: kube-system
56-
spec:
57-
ports:
58-
- port: 443
59-
targetPort: 8000
60-
selector:
61-
app: vpa-admission-controller
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: vpa-webhook
5+
namespace: kube-system
6+
spec:
7+
ports:
8+
- port: 443
9+
targetPort: 8000
10+
selector:
11+
app: vpa-admission-controller

vertical-pod-autoscaler/docs/installation.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,15 @@ To print YAML contents with all resources that would be understood by
138138
The output of that command won't include secret information generated by
139139
[pkg/admission-controller/gencerts.sh](https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler/pkg/admission-controller/gencerts.sh) script.
140140

141+
### Feature gates
142+
143+
To install VPA with feature gates, you can specify the environment variable `$FEATURE_GATES`.
144+
145+
For example, to enable the `InPlaceOrRecreate` feature gate:
146+
```console
147+
FEATURE_GATES=InPlaceOrRecreate=true ./hack/vpa-up.sh
148+
```
149+
141150
## Tear down
142151

143152
Note that if you stop running VPA in your cluster, the resource requests

vertical-pod-autoscaler/hack/deploy-for-e2e-locally.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ for i in ${COMPONENTS}; do
8080
fi
8181
if [ $i == admission-controller ] ; then
8282
(cd ${SCRIPT_ROOT}/pkg/${i} && bash ./gencerts.sh e2e || true)
83+
kubectl apply -f ${SCRIPT_ROOT}/deploy/admission-controller-service.yaml
8384
fi
8485
ALL_ARCHITECTURES=${ARCH} make --directory ${SCRIPT_ROOT}/pkg/${i} docker-build REGISTRY=${REGISTRY} TAG=${TAG}
8586
docker tag ${REGISTRY}/vpa-${i}-${ARCH}:${TAG} ${REGISTRY}/vpa-${i}:${TAG}
8687
kind load docker-image ${REGISTRY}/vpa-${i}:${TAG}
8788
done
8889

89-
9090
for i in ${COMPONENTS}; do
9191
if [ $i == recommender-externalmetrics ] ; then
9292
kubectl delete namespace monitoring --ignore-not-found=true
@@ -96,6 +96,6 @@ for i in ${COMPONENTS}; do
9696
kubectl apply -f ${SCRIPT_ROOT}/hack/e2e/metrics-pump.yaml
9797
kubectl apply -f ${SCRIPT_ROOT}/hack/e2e/${i}-deployment.yaml
9898
else
99-
REGISTRY=${REGISTRY} TAG=${TAG} ${SCRIPT_ROOT}/hack/vpa-process-yaml.sh ${SCRIPT_ROOT}/deploy/${i}-deployment.yaml | kubectl apply -f -
99+
REGISTRY=${REGISTRY} TAG=${TAG} ${SCRIPT_ROOT}/hack/vpa-process-yaml.sh ${SCRIPT_ROOT}/deploy/${i}-deployment.yaml | kubectl apply -f -
100100
fi
101101
done

vertical-pod-autoscaler/hack/deploy-for-e2e.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ gcloud auth configure-docker -q
6969
for i in ${COMPONENTS}; do
7070
if [ $i == admission-controller ] ; then
7171
(cd ${SCRIPT_ROOT}/pkg/${i} && bash ./gencerts.sh e2e || true)
72+
kubectl apply -f ${SCRIPT_ROOT}/deploy/admission-controller-service.yaml
7273
fi
7374
ALL_ARCHITECTURES=amd64 make --directory ${SCRIPT_ROOT}/pkg/${i} release
7475
done
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
kind: Cluster
2+
apiVersion: kind.x-k8s.io/v1alpha4
3+
featureGates:
4+
InPlacePodVerticalScaling: true

vertical-pod-autoscaler/hack/run-e2e-locally.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ kind delete cluster -n kind -q
7575

7676
echo "Creating KIND cluster 'kind'"
7777
KIND_VERSION="kindest/node:v1.32.0"
78-
if ! kind create cluster --image=${KIND_VERSION}; then
78+
if ! kind create cluster --image=${KIND_VERSION} --config ${SCRIPT_ROOT}/hack/kind-config.yaml; then
7979
echo "Failed to create KIND cluster. Exiting. Make sure kind version is updated."
8080
echo "Available versions: https://github.com/kubernetes-sigs/kind/releases"
8181
exit 1

vertical-pod-autoscaler/hack/vpa-process-yaml.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,27 @@ set -o errexit
1818
set -o nounset
1919
set -o pipefail
2020

21-
SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/..
22-
2321
function print_help {
2422
echo "ERROR! Usage: vpa-process-yaml.sh <YAML files>+"
2523
echo "Script will output content of YAML files separated with YAML document"
2624
echo "separator and substituting REGISTRY and TAG for pod images"
2725
}
2826

27+
function apply_feature_gate() {
28+
filename=$1
29+
if [ -n "${FEATURE_GATES}" ]; then
30+
if [[ "${filename}" == *"admission-controller"* ]]; then
31+
kubectl patch --type=json --local -p='[{"op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "--feature-gates='"${FEATURE_GATES}"'"}]' -o yaml -f -
32+
elif [[ "${filename}" == *"updater"* ]] || [[ "${filename}" == *"recommender"* ]]; then
33+
kubectl patch --type=json --local -p='[{"op": "add", "path": "/spec/template/spec/containers/0/args", "value": ["--feature-gates='"${FEATURE_GATES}"'"]}]' -o yaml -f -
34+
else
35+
cat # passthrough
36+
fi
37+
else
38+
cat
39+
fi
40+
}
41+
2942
if [ $# -eq 0 ]; then
3043
print_help
3144
exit 1
@@ -36,6 +49,7 @@ DEFAULT_TAG="1.3.0"
3649

3750
REGISTRY_TO_APPLY=${REGISTRY-$DEFAULT_REGISTRY}
3851
TAG_TO_APPLY=${TAG-$DEFAULT_TAG}
52+
FEATURE_GATES=${FEATURE_GATES:-""}
3953

4054
if [ "${REGISTRY_TO_APPLY}" != "${DEFAULT_REGISTRY}" ]; then
4155
(>&2 echo "WARNING! Using image repository from REGISTRY env variable (${REGISTRY_TO_APPLY}) instead of ${DEFAULT_REGISTRY}.")
@@ -46,7 +60,7 @@ if [ "${TAG_TO_APPLY}" != "${DEFAULT_TAG}" ]; then
4660
fi
4761

4862
for i in $*; do
49-
sed -e "s,${DEFAULT_REGISTRY}/\([a-z-]*\):.*,${REGISTRY_TO_APPLY}/\1:${TAG_TO_APPLY}," $i
63+
sed -e "s,${DEFAULT_REGISTRY}/\([a-z-]*\):.*,${REGISTRY_TO_APPLY}/\1:${TAG_TO_APPLY}," $i | apply_feature_gate "$(basename "$i")"
5064
echo ""
5165
echo "---"
5266
done

vertical-pod-autoscaler/hack/vpa-process-yamls.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,11 @@ for i in $COMPONENTS; do
6666
if [[ ${ACTION} == create || ${ACTION} == apply ]] ; then
6767
# Allow gencerts to fail silently if certs already exist
6868
(bash ${SCRIPT_ROOT}/pkg/admission-controller/gencerts.sh || true)
69+
kubectl apply -f ${SCRIPT_ROOT}/deploy/admission-controller-service.yaml
6970
elif [ ${ACTION} == delete ] ; then
7071
(bash ${SCRIPT_ROOT}/pkg/admission-controller/rmcerts.sh || true)
7172
(bash ${SCRIPT_ROOT}/pkg/admission-controller/delete-webhook.sh || true)
73+
kubectl delete -f ${SCRIPT_ROOT}/deploy/admission-controller-service.yaml
7274
fi
7375
fi
7476
if [[ ${ACTION} == print ]]; then

0 commit comments

Comments
 (0)