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

API for KEP-4831: Control VPA eviction behavior based on scaling direction and resource #5176

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions vertical-pod-autoscaler/deploy/vpa-v1-crd-gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ spec:
description: API version of the referent
type: string
kind:
description: 'Kind of the referent; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds"'
description: 'Kind of the referent; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
name:
description: 'Name of the referent; More info: http://kubernetes.io/docs/user-guide/identifiers#names'
Expand All @@ -379,6 +379,39 @@ spec:
pods. If not specified, all fields in the `PodUpdatePolicy` are
set to their default values.
properties:
evictionRequirements:
description: EvictionRequirements is a list of EvictionRequirements
that need to evaluate to true in order for a Pod to be evicted.
If more than one EvictionRequirement is specified, all of them
need to be fulfilled to allow eviction.
items:
description: EvictionRequirement defines a single condition
which needs to be true in order to evict a Pod
properties:
changeRequirement:
description: EvictionChangeRequirement refers to the relationship
between the new target recommendation for a Pod and its
current requests, what kind of change is necessary for
the Pod to be evicted
enum:
- TargetHigherThanRequests
- TargetLowerThanRequests
type: string
resource:
description: Resources is a list of one or more resources
that the condition applies to. If more than one resource
is given, the EvictionRequirement is fulfilled if at least
one resource meets `changeRequirement`.
items:
description: ResourceName is the name identifying various
resources in a ResourceList.
type: string
type: array
required:
- changeRequirement
- resource
type: object
type: array
minReplicas:
description: Minimal number of replicas which need to be alive
for Updater to attempt pod eviction (pending other checks like
Expand Down Expand Up @@ -607,7 +640,7 @@ spec:
description: API version of the referent
type: string
kind:
description: 'Kind of the referent; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds"'
description: 'Kind of the referent; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
name:
description: 'Name of the referent; More info: http://kubernetes.io/docs/user-guide/identifiers#names'
Expand Down
27 changes: 27 additions & 0 deletions vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,27 @@ type VerticalPodAutoscalerSpec struct {
Recommenders []*VerticalPodAutoscalerRecommenderSelector `json:"recommenders,omitempty" protobuf:"bytes,4,opt,name=recommenders"`
}

// EvictionChangeRequirement refers to the relationship between the new target recommendation for a Pod and its current requests, what kind of change is necessary for the Pod to be evicted
// +kubebuilder:validation:Enum:=TargetHigherThanRequests;TargetLowerThanRequests
type EvictionChangeRequirement string

const (
// TargetHigherThanRequests means the new target recommendation for a Pod is higher than its current requests, i.e. the Pod is scaled up
TargetHigherThanRequests EvictionChangeRequirement = "TargetHigherThanRequests"
// TargetLowerThanRequests means the new target recommendation for a Pod is lower than its current requests, i.e. the Pod is scaled down
TargetLowerThanRequests EvictionChangeRequirement = "TargetLowerThanRequests"
)

// EvictionRequirement defines a single condition which needs to be true in
// order to evict a Pod
type EvictionRequirement struct {
// Resources is a list of one or more resources that the condition applies
// to. If more than one resource is given, the EvictionRequirement is fulfilled
// if at least one resource meets `changeRequirement`.
Resources []v1.ResourceName `json:"resource" protobuf:"bytes,1,name=resources"`
ChangeRequirement EvictionChangeRequirement `json:"changeRequirement" protobuf:"bytes,2,name=changeRequirement"`
}

// PodUpdatePolicy describes the rules on how changes are applied to the pods.
type PodUpdatePolicy struct {
// Controls when autoscaler applies changes to the pod resources.
Expand All @@ -118,6 +139,12 @@ type PodUpdatePolicy struct {
// allowed. Overrides global '--min-replicas' flag.
// +optional
MinReplicas *int32 `json:"minReplicas,omitempty" protobuf:"varint,2,opt,name=minReplicas"`

// EvictionRequirements is a list of EvictionRequirements that need to
// evaluate to true in order for a Pod to be evicted. If more than one
// EvictionRequirement is specified, all of them need to be fulfilled to allow eviction.
// +optional
EvictionRequirements []*EvictionRequirement `json:"evictionRequirements,omitempty" protobuf:"bytes,3,opt,name=evictionRequirements"`
}

// UpdateMode controls when autoscaler applies changes to the pod resources.
Expand Down