-
Notifications
You must be signed in to change notification settings - Fork 4.3k
VPA: Allow e2e tests to reference a custom namespace #8778
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
VPA: Allow e2e tests to reference a custom namespace #8778
Conversation
|
Welcome @AryanBagade! |
|
Hi @AryanBagade. Thanks for your PR. I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Enable VPA e2e tests to use a custom namespace via the VPA_NAMESPACE environment variable, while maintaining backward compatibility with the default kube-system namespace. This addresses issue kubernetes#8752 by making the e2e tests consistent with the VPA components' ability to run in custom namespaces. Changes: - Made VpaNamespace (e2e/v1/common.go) configurable via environment variable - Made RecommenderNamespace (e2e/utils/common.go) configurable via environment variable - Replaced hardcoded kube-system in deleteRecommender() function - Replaced hardcoded kube-system in webhook RoleBinding operations The implementation follows the same pattern as PR kubernetes#7654, using environment variables with sensible defaults to enable custom configurations without breaking existing tests.
6bf0cee to
90f51c8
Compare
|
/release-note-none |
|
Thanks for doing this! /ok-to-test |
omerap12
left a comment
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.
I thought the idea was to do something similar to this:
https://github.com/kubernetes/autoscaler/blob/master/vertical-pod-autoscaler/hack/dev-deploy-locally.sh#L60
(i.e. set the variable names during the binary compilation step)
| ) | ||
|
|
||
| func init() { | ||
| if ns := os.Getenv("VPA_NAMESPACE"); ns != "" { |
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.
What happens if there is no VPA_NAMESPACE env variable?
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.
If the VPA_NAMESPACE environment variable is not set, os.Getenv("VPA_NAMESPACE") returns an empty string, so the condition ns != "" evaluates to false, and we don't override the default value. This means VpaNamespace and RecommenderNamespace remain as "kube-system", maintaining full backward compatibility.
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.
oh I missed the VpaNamespace = "kube-system" above. thanks!
I chose runtime environment variables
But if you prefer the build-time approach, I'm happy to adjust! What do you think? |
| // RecommenderNamespace is namespace to deploy VPA recommender | ||
| RecommenderNamespace = "kube-system" |
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.
I'm wondering if we should just remove this variable and use VpaNamespace for everything if that's possible?
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.
Sure, Sounds good!!
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.
hmmm having two separate variables is redundant since they both serve the same purpose.
The change would be:
- Keep the variable and init() function in
e2e/utils/common.go - Rename
RecommenderNamespace→VpaNamespace - Remove the duplicate from
e2e/v1/common.go - Use
utils.VpaNamespaceeverywhere
Does that sound good? Any other changes i need to make ????
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.
Sure that makes sense to me. Thanks for doing this :-)
|
I also think we need to configure these references too: autoscaler/vertical-pod-autoscaler/e2e/v1/updater.go Lines 45 to 53 in 2eb783b
Right now they will always point to kube-system.
|
|
right, I missed those references. Let me update those as well. |
+1 for me. it follows the other test configurations we've already been using. |
Changes: - Consolidated to single VpaNamespace variable in e2e/utils/common.go - Added VPA_NAMESPACE environment variable support with init() function - Replaced all hardcoded namespace references in e2e tests: - e2e/v1/recommender.go deleteRecommender() function (1 instance) - e2e/v1/updater.go status namespace references (10 instances) - e2e/integration/recommender.go deployment operations (3 instances) - e2e/utils/webhook.go RoleBinding operations (2 instances) - Removed duplicate VpaNamespac from e2e/v1/common.go
|
/lgtm Thanks for the contribution! |
Seems reasonable to me. I agree :) |
omerap12
left a comment
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.
Thanks for this!
/label tide/merge-method-squash
/approve
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: AryanBagade, omerap12 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
VPA: Allow e2e tests to reference a custom namespace (kubernetes#8778) * VPA: Allow e2e tests to reference a custom namespace Enable VPA e2e tests to use a custom namespace via the VPA_NAMESPACE environment variable, while maintaining backward compatibility with the default kube-system namespace. This addresses issue kubernetes#8752 by making the e2e tests consistent with the VPA components' ability to run in custom namespaces. Changes: - Made VpaNamespace (e2e/v1/common.go) configurable via environment variable - Made RecommenderNamespace (e2e/utils/common.go) configurable via environment variable - Replaced hardcoded kube-system in deleteRecommender() function - Replaced hardcoded kube-system in webhook RoleBinding operations The implementation follows the same pattern as PR kubernetes#7654, using environment variables with sensible defaults to enable custom configurations without breaking existing tests. * VPA: Allow e2e tests to reference a custom namespace Changes: - Consolidated to single VpaNamespace variable in e2e/utils/common.go - Added VPA_NAMESPACE environment variable support with init() function - Replaced all hardcoded namespace references in e2e tests: - e2e/v1/recommender.go deleteRecommender() function (1 instance) - e2e/v1/updater.go status namespace references (10 instances) - e2e/integration/recommender.go deployment operations (3 instances) - e2e/utils/webhook.go RoleBinding operations (2 instances) - Removed duplicate VpaNamespac from e2e/v1/common.go Signed-off-by: Max Cao <[email protected]>
VPA: Allow e2e tests to reference a custom namespace (kubernetes#8778) * VPA: Allow e2e tests to reference a custom namespace Enable VPA e2e tests to use a custom namespace via the VPA_NAMESPACE environment variable, while maintaining backward compatibility with the default kube-system namespace. This addresses issue kubernetes#8752 by making the e2e tests consistent with the VPA components' ability to run in custom namespaces. Changes: - Made VpaNamespace (e2e/v1/common.go) configurable via environment variable - Made RecommenderNamespace (e2e/utils/common.go) configurable via environment variable - Replaced hardcoded kube-system in deleteRecommender() function - Replaced hardcoded kube-system in webhook RoleBinding operations The implementation follows the same pattern as PR kubernetes#7654, using environment variables with sensible defaults to enable custom configurations without breaking existing tests. * VPA: Allow e2e tests to reference a custom namespace Changes: - Consolidated to single VpaNamespace variable in e2e/utils/common.go - Added VPA_NAMESPACE environment variable support with init() function - Replaced all hardcoded namespace references in e2e tests: - e2e/v1/recommender.go deleteRecommender() function (1 instance) - e2e/v1/updater.go status namespace references (10 instances) - e2e/integration/recommender.go deployment operations (3 instances) - e2e/utils/webhook.go RoleBinding operations (2 instances) - Removed duplicate VpaNamespac from e2e/v1/common.go Signed-off-by: Max Cao <[email protected]>
VPA: Allow e2e tests to reference a custom namespace (kubernetes#8778) * VPA: Allow e2e tests to reference a custom namespace Enable VPA e2e tests to use a custom namespace via the VPA_NAMESPACE environment variable, while maintaining backward compatibility with the default kube-system namespace. This addresses issue kubernetes#8752 by making the e2e tests consistent with the VPA components' ability to run in custom namespaces. Changes: - Made VpaNamespace (e2e/v1/common.go) configurable via environment variable - Made RecommenderNamespace (e2e/utils/common.go) configurable via environment variable - Replaced hardcoded kube-system in deleteRecommender() function - Replaced hardcoded kube-system in webhook RoleBinding operations The implementation follows the same pattern as PR kubernetes#7654, using environment variables with sensible defaults to enable custom configurations without breaking existing tests. * VPA: Allow e2e tests to reference a custom namespace Changes: - Consolidated to single VpaNamespace variable in e2e/utils/common.go - Added VPA_NAMESPACE environment variable support with init() function - Replaced all hardcoded namespace references in e2e tests: - e2e/v1/recommender.go deleteRecommender() function (1 instance) - e2e/v1/updater.go status namespace references (10 instances) - e2e/integration/recommender.go deployment operations (3 instances) - e2e/utils/webhook.go RoleBinding operations (2 instances) - Removed duplicate VpaNamespac from e2e/v1/common.go Signed-off-by: Max Cao <[email protected]>
* VPA: Allow e2e tests to reference a custom namespace Enable VPA e2e tests to use a custom namespace via the VPA_NAMESPACE environment variable, while maintaining backward compatibility with the default kube-system namespace. This addresses issue kubernetes#8752 by making the e2e tests consistent with the VPA components' ability to run in custom namespaces. Changes: - Made VpaNamespace (e2e/v1/common.go) configurable via environment variable - Made RecommenderNamespace (e2e/utils/common.go) configurable via environment variable - Replaced hardcoded kube-system in deleteRecommender() function - Replaced hardcoded kube-system in webhook RoleBinding operations The implementation follows the same pattern as PR kubernetes#7654, using environment variables with sensible defaults to enable custom configurations without breaking existing tests. * VPA: Allow e2e tests to reference a custom namespace Changes: - Consolidated to single VpaNamespace variable in e2e/utils/common.go - Added VPA_NAMESPACE environment variable support with init() function - Replaced all hardcoded namespace references in e2e tests: - e2e/v1/recommender.go deleteRecommender() function (1 instance) - e2e/v1/updater.go status namespace references (10 instances) - e2e/integration/recommender.go deployment operations (3 instances) - e2e/utils/webhook.go RoleBinding operations (2 instances) - Removed duplicate VpaNamespac from e2e/v1/common.go
What type of PR is this?
/kind feature
What this PR does / why we need it:
Enables VPA e2e tests to use a custom namespace via the
VPA_NAMESPACEenvironment variable, while maintaining backward compatibility with the defaultkube-systemnamespace.This makes the e2e tests consistent with the VPA components' ability to run in custom namespaces, as mentioned in issue #8752.
Which issue(s) this PR fixes:
Fixes #8752
Special notes for your reviewer:
This implementation follows the same pattern as PR #7654, using environment variables with sensible defaults to enable custom configurations without breaking existing tests.
The changes are minimal and only affect e2e test code:
VpaNamespace(e2e/v1/common.go) configurable viaVPA_NAMESPACEenv varRecommenderNamespace(e2e/utils/common.go) configurable viaVPA_NAMESPACEenv varkube-systemstrings indeleteRecommender()functionkube-systemstrings in webhook RoleBinding operationsAll unit tests pass with race detection enabled.
Does this PR introduce a user-facing change?