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

WIP: Descheduling framework PoC #781

Closed
Closed
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
2 changes: 1 addition & 1 deletion hack/update-generated-conversions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ go build -o "${OS_OUTPUT_BINPATH}/conversion-gen" "k8s.io/code-generator/cmd/con

${OS_OUTPUT_BINPATH}/conversion-gen \
--go-header-file "hack/boilerplate/boilerplate.go.txt" \
--input-dirs "${PRJ_PREFIX}/pkg/apis/componentconfig/v1alpha1,${PRJ_PREFIX}/pkg/api/v1alpha1" \
--input-dirs "${PRJ_PREFIX}/pkg/apis/componentconfig/v1alpha1,${PRJ_PREFIX}/pkg/api/v1alpha1,${PRJ_PREFIX}/pkg/api/v1alpha2" \
--output-file-base zz_generated.conversion
3 changes: 1 addition & 2 deletions hack/update-generated-deep-copies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ go build -o "${OS_OUTPUT_BINPATH}/deepcopy-gen" "k8s.io/code-generator/cmd/deepc

${OS_OUTPUT_BINPATH}/deepcopy-gen \
--go-header-file "hack/boilerplate/boilerplate.go.txt" \
--input-dirs "${PRJ_PREFIX}/pkg/apis/componentconfig,${PRJ_PREFIX}/pkg/apis/componentconfig/v1alpha1,${PRJ_PREFIX}/pkg/api,${PRJ_PREFIX}/pkg/api/v1alpha1" \
--input-dirs "${PRJ_PREFIX}/pkg/apis/componentconfig,${PRJ_PREFIX}/pkg/apis/componentconfig/v1alpha1,${PRJ_PREFIX}/pkg/api,${PRJ_PREFIX}/pkg/api/v1alpha1,${PRJ_PREFIX}/pkg/api/v1alpha2" \
--output-file-base zz_generated.deepcopy

4 changes: 2 additions & 2 deletions hack/update-generated-defaulters.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ go build -o "${OS_OUTPUT_BINPATH}/defaulter-gen" "k8s.io/code-generator/cmd/defa

${OS_OUTPUT_BINPATH}/defaulter-gen \
--go-header-file "hack/boilerplate/boilerplate.go.txt" \
--input-dirs "${PRJ_PREFIX}/pkg/apis/componentconfig/v1alpha1,${PRJ_PREFIX}/pkg/api/v1alpha1" \
--extra-peer-dirs "${PRJ_PREFIX}/pkg/apis/componentconfig/v1alpha1,${PRJ_PREFIX}/pkg/api/v1alpha1" \
--input-dirs "${PRJ_PREFIX}/pkg/apis/componentconfig/v1alpha1,${PRJ_PREFIX}/pkg/api/v1alpha1,${PRJ_PREFIX}/pkg/api/v1alpha2" \
--extra-peer-dirs "${PRJ_PREFIX}/pkg/apis/componentconfig/v1alpha1,${PRJ_PREFIX}/pkg/api/v1alpha1,${PRJ_PREFIX}/pkg/api/v1alpha2" \
--output-file-base zz_generated.defaults
158 changes: 158 additions & 0 deletions pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package api
import (
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down Expand Up @@ -72,6 +73,11 @@ type Namespaces struct {
Exclude []string
}

type PriorityThreshold struct {
Value *int32
Name string
}

// Besides Namespaces only one of its members may be specified
// TODO(jchaloup): move Namespaces ThresholdPriority and ThresholdPriorityClassName to individual strategies
// once the policy version is bumped to v1alpha2
Expand Down Expand Up @@ -122,3 +128,155 @@ type FailedPods struct {
Reasons []string
IncludingInitContainers bool
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type DeschedulerConfiguration struct {
metav1.TypeMeta

// Profiles
Profiles []Profile

// NodeSelector for a set of nodes to operate over
NodeSelector *string

// MaxNoOfPodsToEvictPerNode restricts maximum of pods to be evicted per node.
MaxNoOfPodsToEvictPerNode *int

// MaxNoOfPodsToEvictPerNamespace restricts maximum of pods to be evicted per namespace.
MaxNoOfPodsToEvictPerNamespace *int
}

type Profile struct {
Name string
PluginConfig []PluginConfig
Plugins Plugins
}

type Plugins struct {
PreSort Plugin
Deschedule Plugin
Balance Plugin
Sort Plugin
Evict Plugin
}

type PluginConfig struct {
Name string
Args runtime.Object
}

type Plugin struct {
Enabled []string
Disabled []string
}

// RemoveDuplicatePodsArgs holds arguments used to configure the RemoveDuplicatePods plugin.
type RemoveDuplicatePodsArgs struct {
metav1.TypeMeta

Namespaces *Namespaces
ExcludeOwnerKinds []string
}

// RemoveFailedPodsArgs holds arguments used to configure the RemoveFailedPods plugin.
type RemoveFailedPodsArgs struct {
metav1.TypeMeta

Namespaces *Namespaces
LabelSelector *metav1.LabelSelector
MinPodLifetimeSeconds *uint
Reasons []string
IncludingInitContainers bool
ExcludeOwnerKinds []string
}

// RemovePodsViolatingNodeAffinityArgs holds arguments used to configure the RemovePodsViolatingNodeAffinity plugin.
type RemovePodsViolatingNodeAffinityArgs struct {
metav1.TypeMeta

Namespaces *Namespaces
LabelSelector *metav1.LabelSelector
NodeAffinityType []string
}

// RemovePodsViolatingNodeTaintsArgs holds arguments used to configure the RemovePodsViolatingNodeTaints plugin.
type RemovePodsViolatingNodeTaintsArgs struct {
metav1.TypeMeta

Namespaces *Namespaces
LabelSelector *metav1.LabelSelector
IncludePreferNoSchedule bool
ExcludedTaints []string
}

// RemovePodsViolatingInterPodAntiAffinityArgs holds arguments used to configure the RemovePodsViolatingInterPodAntiAffinity plugin.
type RemovePodsViolatingInterPodAntiAffinityArgs struct {
metav1.TypeMeta

Namespaces *Namespaces
LabelSelector *metav1.LabelSelector
}

// PodLifeTimeArgs holds arguments used to configure the PodLifeTime plugin.
type PodLifeTimeArgs struct {
metav1.TypeMeta

Namespaces *Namespaces
LabelSelector *metav1.LabelSelector
MaxPodLifeTimeSeconds *uint
PodStatusPhases []string
}

// RemovePodsHavingTooManyRestartsArgs holds arguments used to configure the RemovePodsHavingTooManyRestarts plugin.
type RemovePodsHavingTooManyRestartsArgs struct {
metav1.TypeMeta

Namespaces *Namespaces
LabelSelector *metav1.LabelSelector
PodRestartThreshold int32
IncludingInitContainers bool
}

// RemovePodsViolatingTopologySpreadConstraintArgs holds arguments used to configure the RemovePodsViolatingTopologySpreadConstraint plugin.
type RemovePodsViolatingTopologySpreadConstraintArgs struct {
metav1.TypeMeta

Namespaces *Namespaces
LabelSelector *metav1.LabelSelector
IncludeSoftConstraints bool
}

// LowNodeUtilizationArgs holds arguments used to configure the LowNodeUtilization plugin.
type LowNodeUtilizationArgs struct {
metav1.TypeMeta

UseDeviationThresholds bool
Thresholds ResourceThresholds
TargetThresholds ResourceThresholds
NumberOfNodes int
}

// HighNodeUtilizationArgs holds arguments used to configure the HighNodeUtilization plugin.
type HighNodeUtilizationArgs struct {
metav1.TypeMeta

Thresholds ResourceThresholds
TargetThresholds ResourceThresholds
NumberOfNodes int
}

// DefaultEvictorArgs holds arguments used to configure the DefaultEvictor plugin.
type DefaultEvictorArgs struct {
metav1.TypeMeta

EvictFailedBarePods bool
EvictLocalStoragePods bool
EvictSystemCriticalPods bool
IgnorePvcPods bool
PriorityThreshold *PriorityThreshold
NodeFit bool
LabelSelector *metav1.LabelSelector
// TODO(jchaloup): turn it into *metav1.LabelSelector
NodeSelector string
}
23 changes: 23 additions & 0 deletions pkg/api/v1alpha2/defaults.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Copyright 2017 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha2

import "k8s.io/apimachinery/pkg/runtime"

func addDefaultingFuncs(scheme *runtime.Scheme) error {
return RegisterDefaults(scheme)
}
24 changes: 24 additions & 0 deletions pkg/api/v1alpha2/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Copyright 2017 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// +k8s:deepcopy-gen=package,register
// +k8s:conversion-gen=sigs.k8s.io/descheduler/pkg/api
// +k8s:defaulter-gen=TypeMeta

// Package v1alpha2 is the v1alpha2 version of the descheduler API
// +groupName=descheduler

package v1alpha2 // import "sigs.k8s.io/descheduler/pkg/api/v1alpha2"
126 changes: 126 additions & 0 deletions pkg/api/v1alpha2/plugin_args.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
package v1alpha2

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"sigs.k8s.io/descheduler/pkg/api"
)

// RemoveDuplicatePodsArgs holds arguments used to configure the RemoveDuplicatePods plugin.
type RemoveDuplicatePodsArgs struct {
metav1.TypeMeta

Namespaces *api.Namespaces `json:"namespaces"`
ExcludeOwnerKinds []string `json:"excludeOwnerKinds"`
}

// RemoveFailedPodsArgs holds arguments used to configure the RemoveFailedPods plugin.
type RemoveFailedPodsArgs struct {
metav1.TypeMeta

Namespaces *api.Namespaces `json:"namespaces"`
LabelSelector *metav1.LabelSelector `json:"labelSelector"`
MinPodLifetimeSeconds *uint `json:"minPodLifetimeSeconds"`
Reasons []string `json:"reasons"`
IncludingInitContainers bool `json:"includingInitContainers"`
ExcludeOwnerKinds []string `json:"excludeOwnerKinds"`
}

// RemovePodsViolatingNodeAffinityArgs holds arguments used to configure the RemovePodsViolatingNodeAffinity plugin.
type RemovePodsViolatingNodeAffinityArgs struct {
metav1.TypeMeta

Namespaces *api.Namespaces `json:"namespaces"`
LabelSelector *metav1.LabelSelector `json:"labelSelector"`
NodeAffinityType []string `json:"nodeAffinityType"`
}

// RemovePodsViolatingNodeTaintsArgs holds arguments used to configure the RemovePodsViolatingNodeTaints plugin.
type RemovePodsViolatingNodeTaintsArgs struct {
metav1.TypeMeta

Namespaces *api.Namespaces `json:"namespaces"`
LabelSelector *metav1.LabelSelector `json:"labelSelector"`
IncludePreferNoSchedule bool `json:"includePreferNoSchedule"`
ExcludedTaints []string `json:"excludedTaints"`
}

// RemovePodsViolatingInterPodAntiAffinityArgs holds arguments used to configure the RemovePodsViolatingInterPodAntiAffinity plugin.
type RemovePodsViolatingInterPodAntiAffinityArgs struct {
metav1.TypeMeta

Namespaces *api.Namespaces `json:"namespaces"`
LabelSelector *metav1.LabelSelector `json:"labelSelector"`
}

// PodLifeTimeArgs holds arguments used to configure the PodLifeTime plugin.
type PodLifeTimeArgs struct {
metav1.TypeMeta

Namespaces *api.Namespaces `json:"namespaces"`
LabelSelector *metav1.LabelSelector `json:"labelSelector"`
MaxPodLifeTimeSeconds *uint `json:"maxPodLifeTimeSeconds"`
PodStatusPhases []string `json:"podStatusPhases"`
}

// RemovePodsHavingTooManyRestartsArgs holds arguments used to configure the RemovePodsHavingTooManyRestarts plugin.
type RemovePodsHavingTooManyRestartsArgs struct {
metav1.TypeMeta

Namespaces *api.Namespaces `json:"namespaces"`
LabelSelector *metav1.LabelSelector `json:"labelSelector"`
PodRestartThreshold int32 `json:"podRestartThreshold"`
IncludingInitContainers bool `json:"includingInitContainers"`
}

// RemovePodsViolatingTopologySpreadConstraintArgs holds arguments used to configure the RemovePodsViolatingTopologySpreadConstraint plugin.
type RemovePodsViolatingTopologySpreadConstraintArgs struct {
metav1.TypeMeta

Namespaces *api.Namespaces `json:"namespaces"`
LabelSelector *metav1.LabelSelector `json:"labelSelector"`
IncludeSoftConstraints bool `json:"includeSoftConstraints"`
}

// LowNodeUtilizationArgs holds arguments used to configure the LowNodeUtilization plugin.
type LowNodeUtilizationArgs struct {
metav1.TypeMeta

UseDeviationThresholds bool `json:"useDeviationThresholds"`
Thresholds api.ResourceThresholds `json:"thresholds"`
TargetThresholds api.ResourceThresholds `json:"targetThresholds"`
NumberOfNodes int `json:"numberOfNodes"`
}

// HighNodeUtilizationArgs holds arguments used to configure the HighNodeUtilization plugin.
type HighNodeUtilizationArgs struct {
metav1.TypeMeta

Thresholds api.ResourceThresholds `json:"thresholds"`
// TODO(jchaloup): remove TargetThresholds
TargetThresholds api.ResourceThresholds `json:"targetThresholds"`
NumberOfNodes int `json:"numberOfNodes"`
}

// DefaultEvictorArgs holds arguments used to configure the DefaultEvictor plugin.
type DefaultEvictorArgs struct {
metav1.TypeMeta

// EvictFailedBarePods allows pods without ownerReferences and in failed phase to be evicted.
EvictFailedBarePods bool `json:"evictFailedBarePods"`

// EvictLocalStoragePods allows pods using local storage to be evicted.
EvictLocalStoragePods bool `json:"evictLocalStoragePods"`

// EvictSystemCriticalPods allows eviction of pods of any priority (including Kubernetes system pods)
EvictSystemCriticalPods bool `json:"evictSystemCriticalPods"`

// IgnorePVCPods prevents pods with PVCs from being evicted.
IgnorePvcPods bool `json:"ignorePvcPods"`

PriorityThreshold *api.PriorityThreshold `json:"priorityThreshold"`
NodeFit bool `json:"nodeFit"`
LabelSelector *metav1.LabelSelector `json:"labelSelector"`
// TODO(jchaloup): turn it into *metav1.LabelSelector `json:"labelSelector"`
NodeSelector string `json:"nodeSelector"`
}
Loading