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

Add a command line option to limit which resources can be applied #101

Conversation

domenicbozzuto
Copy link

Add the ability to prevent all VPA recommendations from being applied to a target pod. This adds a new command line optoin --allowedResources that can be set like allowedResources=cpu,memory to control which resources can be applied to pods.

This should prevent an issue where values we're setting in our VPA objects for non-standard resources are attempting to be applied, but are not advertised extended resources, so they cannot be set.

@domenicbozzuto domenicbozzuto marked this pull request as draft February 22, 2024 19:47
Copy link

@dbenque dbenque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we deal with CPU and Mem the same way for the filtering, having them by default in the allowedList ?

@@ -69,6 +70,7 @@ var (
registerWebhook = flag.Bool("register-webhook", true, "If set to true, admission webhook object will be created on start up to register with the API server.")
registerByURL = flag.Bool("register-by-url", false, "If set to true, admission webhook will be registered by URL (webhookAddress:webhookPort) instead of by service name")
vpaObjectNamespace = flag.String("vpa-object-namespace", apiv1.NamespaceAll, "Namespace to search for VPA objects. Empty means all namespaces will be used.")
allowedResources = flag.String("allowed-resources", "", "Comma-separated allow list of resources that can be applied by this controller. Empty means any recommendation can be applied")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we default to CPU and Memory ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, I was originally thinking avoid changing behavior by treating "" as allow everything, but that should be the same as setting cpu/memory as the default options, updated


func filterResourceList(resourceList core.ResourceList, allowedResources []core.ResourceName) core.ResourceList {
if len(allowedResources) == 0 {
return resourceList
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have expected that an empty allowedResources would result in an empty output: everything filtered out

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, removed this check and now the entire list is filtered out if allowedResources is empty

@domenicbozzuto domenicbozzuto force-pushed the dom.bozzuto/allow-filtering-resources-applied-at-admission branch from a56945e to 94a6a13 Compare February 22, 2024 21:05
@domenicbozzuto domenicbozzuto force-pushed the dom.bozzuto/allow-filtering-resources-applied-at-admission branch from 94a6a13 to c3213da Compare February 22, 2024 22:26
@dbenque
Copy link

dbenque commented Feb 23, 2024

LGTM, ready for final review ?

@domenicbozzuto
Copy link
Author

After revisiting a bit, I decided this was better to implement as a separate RecommendationProcessor rather than just hacking it into the recommendationProvider. I opened #102 with the new set of changes (core implementation is the same, just a different structure)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants