Skip to content

Commit

Permalink
Added option to use VpaMinReplicasAnnotation from labels (#720)
Browse files Browse the repository at this point in the history
* Added option to use VpaMinReplicasAnnotation from labels

* Update vpa pod resource policy to also allow the use of labels

* ci: trigger build

---------

Co-authored-by: Andy Suderman <[email protected]>
  • Loading branch information
devantler and sudermanjr authored Jul 29, 2024
1 parent 1b42caf commit 2be84ac
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/vpa/vpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ func vpaResourcePolicyForResource(obj runtime.Object) (*vpav1.PodResourcePolicy,
accessor, _ := meta.Accessor(obj)
if val, ok := accessor.GetAnnotations()[utils.VpaResourcePolicyAnnotation]; ok {
resourcePolicyStr = val
} else if val, ok := accessor.GetLabels()[utils.VpaResourcePolicyAnnotation]; ok {
resourcePolicyStr = val
}

if resourcePolicyStr == "" {
Expand All @@ -436,6 +438,8 @@ func vpaMinReplicasForResource(obj runtime.Object) (*int32, bool) {
accessor, _ := meta.Accessor(obj)
if val, ok := accessor.GetAnnotations()[utils.VpaMinReplicasAnnotation]; ok {
minReplicasString = val
} else if val, ok := accessor.GetLabels()[utils.VpaMinReplicasAnnotation]; ok {
minReplicasString = val
}

if minReplicasString == "" {
Expand Down

0 comments on commit 2be84ac

Please sign in to comment.