-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat(vpa): use Helm chart for local E2E testing and dev deployment #8990
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,35 +67,108 @@ esac | |
| export REGISTRY=${REGISTRY:-localhost:5001} | ||
| export TAG=${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 | ||
| # Deploy metrics server for E2E tests | ||
| kubectl apply -f ${SCRIPT_ROOT}/hack/e2e/k8s-metrics-server.yaml | ||
|
|
||
| # Build and load Docker images for each component | ||
| for i in ${COMPONENTS}; do | ||
| COMPONENT_NAME=$i | ||
| if [ $i == recommender-externalmetrics ] ; then | ||
| i=recommender | ||
| COMPONENT_NAME=recommender | ||
| fi | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if it makes sense to modify the case statement on line 50 to add: Then this exception doesn't need to be handled here, and line 96 lower down can also be neater. |
||
| if [ $i == admission-controller ] ; then | ||
| (cd ${SCRIPT_ROOT}/pkg/${i} && bash ./gencerts.sh e2e || true) | ||
| kubectl apply -f ${SCRIPT_ROOT}/deploy/admission-controller-service.yaml | ||
| 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} | ||
| ALL_ARCHITECTURES=${ARCH} make --directory ${SCRIPT_ROOT}/pkg/${COMPONENT_NAME} docker-build REGISTRY=${REGISTRY} TAG=${TAG} | ||
| docker tag ${REGISTRY}/vpa-${COMPONENT_NAME}-${ARCH}:${TAG} ${REGISTRY}/vpa-${COMPONENT_NAME}:${TAG} | ||
| kind load docker-image ${REGISTRY}/vpa-${COMPONENT_NAME}:${TAG} | ||
| done | ||
|
|
||
| # Prepare Helm values | ||
| HELM_CHART_PATH="${SCRIPT_ROOT}/charts/vertical-pod-autoscaler" | ||
| VALUES_FILE="${SCRIPT_ROOT}/hack/e2e/values-e2e-local.yaml" | ||
| HELM_RELEASE_NAME="vpa" | ||
| HELM_NAMESPACE="kube-system" | ||
|
|
||
| # Build dynamic Helm set arguments based on components | ||
| HELM_SET_ARGS="" | ||
|
|
||
| # Enable components based on suite | ||
| 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 | ||
| case $i in | ||
| recommender|recommender-externalmetrics) | ||
| HELM_SET_ARGS="${HELM_SET_ARGS} --set recommender.enabled=true" | ||
| HELM_SET_ARGS="${HELM_SET_ARGS} --set recommender.image.repository=${REGISTRY}/vpa-recommender" | ||
| HELM_SET_ARGS="${HELM_SET_ARGS} --set recommender.image.tag=${TAG}" | ||
| ;; | ||
| updater) | ||
| HELM_SET_ARGS="${HELM_SET_ARGS} --set updater.enabled=true" | ||
| HELM_SET_ARGS="${HELM_SET_ARGS} --set updater.image.repository=${REGISTRY}/vpa-updater" | ||
| HELM_SET_ARGS="${HELM_SET_ARGS} --set updater.image.tag=${TAG}" | ||
| ;; | ||
| admission-controller) | ||
| HELM_SET_ARGS="${HELM_SET_ARGS} --set admissionController.enabled=true" | ||
| HELM_SET_ARGS="${HELM_SET_ARGS} --set admissionController.image.repository=${REGISTRY}/vpa-admission-controller" | ||
| HELM_SET_ARGS="${HELM_SET_ARGS} --set admissionController.image.tag=${TAG}" | ||
| ;; | ||
| esac | ||
|
Comment on lines
+95
to
+111
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am wondering if it will be better to have a dedicated values file for each (with default configurations) , and then developers could just tweak the files as they see fit?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ohh we already have this here: vertical-pod-autoscaler/hack/e2e/values-e2e-local.yaml , so this is just for the image repo and tag. makes sense to me. |
||
| done | ||
|
|
||
| # Add feature gates if specified | ||
| if [ -n "${FEATURE_GATES:-}" ]; then | ||
| # Add feature gates to each enabled component | ||
| for i in ${COMPONENTS}; do | ||
| case $i in | ||
| recommender|recommender-externalmetrics) | ||
| HELM_SET_ARGS="${HELM_SET_ARGS} --set recommender.extraArgs[0]=--feature-gates=${FEATURE_GATES}" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a thought, and your PR doesn't need to address this: The helm chart could cater for feature flags, that way we don't need to use extraArgs for it
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 |
||
| ;; | ||
| updater) | ||
| HELM_SET_ARGS="${HELM_SET_ARGS} --set updater.extraArgs[0]=--feature-gates=${FEATURE_GATES}" | ||
| ;; | ||
| admission-controller) | ||
| HELM_SET_ARGS="${HELM_SET_ARGS} --set admissionController.extraArgs[0]=--feature-gates=${FEATURE_GATES}" | ||
| ;; | ||
| esac | ||
| done | ||
| fi | ||
|
|
||
| # Uninstall any existing VPA Helm release | ||
| helm uninstall ${HELM_RELEASE_NAME} --namespace ${HELM_NAMESPACE} 2>/dev/null || true | ||
|
|
||
| # Install VPA using Helm chart | ||
| echo " ** Installing VPA via Helm chart" | ||
| helm install ${HELM_RELEASE_NAME} ${HELM_CHART_PATH} \ | ||
| --namespace ${HELM_NAMESPACE} \ | ||
| --values ${VALUES_FILE} \ | ||
| ${HELM_SET_ARGS} \ | ||
| --wait | ||
|
Comment on lines
+135
to
+141
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because this is an e2e testing it may be useful to add |
||
|
|
||
| # Handle external metrics special case | ||
| if [[ "${SUITE}" == "recommender-externalmetrics" ]]; then | ||
| echo " ** Setting up external metrics infrastructure" | ||
|
|
||
| # Apply extra RBAC for external metrics | ||
| 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 | ||
|
Comment on lines
+147
to
+150
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The helm chart should handle this.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 |
||
|
|
||
| # Deploy Prometheus and adapter for external metrics | ||
| 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 | ||
|
|
||
| # Upgrade Helm release with external metrics configuration | ||
| echo " ** Updating recommender with external metrics args" | ||
| # Determine starting index for external metrics args (after feature gates if set) | ||
| EXTERNAL_METRICS_START_INDEX=0 | ||
| if [ -n "${FEATURE_GATES:-}" ]; then | ||
| EXTERNAL_METRICS_START_INDEX=1 | ||
| fi | ||
| helm upgrade ${HELM_RELEASE_NAME} ${HELM_CHART_PATH} \ | ||
| --namespace ${HELM_NAMESPACE} \ | ||
| --values ${VALUES_FILE} \ | ||
| ${HELM_SET_ARGS} \ | ||
| --set "recommender.extraArgs[${EXTERNAL_METRICS_START_INDEX}]=--use-external-metrics=true" \ | ||
| --set "recommender.extraArgs[$((EXTERNAL_METRICS_START_INDEX + 1))]=--external-metrics-cpu-metric=cpu" \ | ||
| --set "recommender.extraArgs[$((EXTERNAL_METRICS_START_INDEX + 2))]=--external-metrics-memory-metric=mem" \ | ||
| --wait | ||
| fi | ||
|
Comment on lines
+144
to
+174
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could this block all happen before the |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ REQUIRED_COMMANDS=" | |
| docker | ||
| git | ||
| go | ||
| helm | ||
| kubectl | ||
| make | ||
| " | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # Helm values for local E2E testing | ||
| # Used by deploy-for-e2e-locally.sh | ||
|
|
||
| # Image settings - will be overridden via --set at install time | ||
| # admissionController.image.repository, admissionController.image.tag, etc. | ||
|
|
||
| # Pod security context | ||
| podSecurityContext: | ||
| runAsNonRoot: true | ||
| runAsUser: 65534 | ||
|
Comment on lines
+7
to
+10
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do really need we need to add this? |
||
|
|
||
| # Component configurations optimized for local KIND cluster | ||
| admissionController: | ||
| enabled: false # Enabled dynamically based on suite | ||
| replicas: 1 | ||
| image: | ||
| pullPolicy: Never | ||
| # Disable pod anti-affinity for single-node clusters | ||
| affinity: {} | ||
| podDisruptionBudget: | ||
| enabled: false | ||
| # Use Helm-managed webhook (certgen creates certificates) | ||
| registerWebhook: false | ||
| certGen: | ||
| enabled: true | ||
|
|
||
| recommender: | ||
| enabled: false # Enabled dynamically based on suite | ||
| replicas: 1 | ||
| image: | ||
| pullPolicy: Never | ||
| # Disable pod anti-affinity for single-node clusters | ||
| affinity: {} | ||
| podDisruptionBudget: | ||
| enabled: false | ||
| # Disable leader election for single replica | ||
| leaderElection: | ||
| enabled: false | ||
|
|
||
| updater: | ||
| enabled: false # Enabled dynamically based on suite | ||
| replicas: 1 | ||
| image: | ||
| pullPolicy: Never | ||
| # Disable pod anti-affinity for single-node clusters | ||
| affinity: {} | ||
| podDisruptionBudget: | ||
| enabled: false | ||
| # Disable leader election for single replica | ||
| leaderElection: | ||
| enabled: false | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be simplified:
However, I'd prefer the following:
But I'm not strongly opinionated on that.