v1alpha1

package
v0.29.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2023 License: Apache-2.0 Imports: 27 Imported by: 1

Documentation

Index

Constants

View Source
const (
	GroupName    = "descheduler"
	GroupVersion = "v1alpha1"
)

GroupName is the group name used in this package

Variables

View Source
var (
	SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)

	AddToScheme = SchemeBuilder.AddToScheme
)
View Source
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: GroupVersion}

SchemeGroupVersion is group version used to register these objects

View Source
var StrategyParamsToPluginArgs = map[string]func(params *StrategyParameters) (*api.PluginConfig, error){
	"RemovePodsViolatingNodeTaints": func(params *StrategyParameters) (*api.PluginConfig, error) {
		args := &removepodsviolatingnodetaints.RemovePodsViolatingNodeTaintsArgs{
			Namespaces:              v1alpha1NamespacesToInternal(params.Namespaces),
			LabelSelector:           params.LabelSelector,
			IncludePreferNoSchedule: params.IncludePreferNoSchedule,
			ExcludedTaints:          params.ExcludedTaints,
		}
		if err := removepodsviolatingnodetaints.ValidateRemovePodsViolatingNodeTaintsArgs(args); err != nil {
			klog.ErrorS(err, "unable to validate plugin arguments", "pluginName", removepodsviolatingnodetaints.PluginName)
			return nil, fmt.Errorf("strategy %q param validation failed: %v", removepodsviolatingnodetaints.PluginName, err)
		}
		return &api.PluginConfig{
			Name: removepodsviolatingnodetaints.PluginName,
			Args: args,
		}, nil
	},
	"RemoveFailedPods": func(params *StrategyParameters) (*api.PluginConfig, error) {
		failedPodsParams := params.FailedPods
		if failedPodsParams == nil {
			failedPodsParams = &FailedPods{}
		}
		args := &removefailedpods.RemoveFailedPodsArgs{
			Namespaces:              v1alpha1NamespacesToInternal(params.Namespaces),
			LabelSelector:           params.LabelSelector,
			IncludingInitContainers: failedPodsParams.IncludingInitContainers,
			MinPodLifetimeSeconds:   failedPodsParams.MinPodLifetimeSeconds,
			ExcludeOwnerKinds:       failedPodsParams.ExcludeOwnerKinds,
			Reasons:                 failedPodsParams.Reasons,
		}
		if err := removefailedpods.ValidateRemoveFailedPodsArgs(args); err != nil {
			klog.ErrorS(err, "unable to validate plugin arguments", "pluginName", removefailedpods.PluginName)
			return nil, fmt.Errorf("strategy %q param validation failed: %v", removefailedpods.PluginName, err)
		}
		return &api.PluginConfig{
			Name: removefailedpods.PluginName,
			Args: args,
		}, nil
	},
	"RemovePodsViolatingNodeAffinity": func(params *StrategyParameters) (*api.PluginConfig, error) {
		args := &removepodsviolatingnodeaffinity.RemovePodsViolatingNodeAffinityArgs{
			Namespaces:       v1alpha1NamespacesToInternal(params.Namespaces),
			LabelSelector:    params.LabelSelector,
			NodeAffinityType: params.NodeAffinityType,
		}
		if err := removepodsviolatingnodeaffinity.ValidateRemovePodsViolatingNodeAffinityArgs(args); err != nil {
			klog.ErrorS(err, "unable to validate plugin arguments", "pluginName", removepodsviolatingnodeaffinity.PluginName)
			return nil, fmt.Errorf("strategy %q param validation failed: %v", removepodsviolatingnodeaffinity.PluginName, err)
		}
		return &api.PluginConfig{
			Name: removepodsviolatingnodeaffinity.PluginName,
			Args: args,
		}, nil
	},
	"RemovePodsViolatingInterPodAntiAffinity": func(params *StrategyParameters) (*api.PluginConfig, error) {
		args := &removepodsviolatinginterpodantiaffinity.RemovePodsViolatingInterPodAntiAffinityArgs{
			Namespaces:    v1alpha1NamespacesToInternal(params.Namespaces),
			LabelSelector: params.LabelSelector,
		}
		if err := removepodsviolatinginterpodantiaffinity.ValidateRemovePodsViolatingInterPodAntiAffinityArgs(args); err != nil {
			klog.ErrorS(err, "unable to validate plugin arguments", "pluginName", removepodsviolatinginterpodantiaffinity.PluginName)
			return nil, fmt.Errorf("strategy %q param validation failed: %v", removepodsviolatinginterpodantiaffinity.PluginName, err)
		}
		return &api.PluginConfig{
			Name: removepodsviolatinginterpodantiaffinity.PluginName,
			Args: args,
		}, nil
	},
	"RemovePodsHavingTooManyRestarts": func(params *StrategyParameters) (*api.PluginConfig, error) {
		tooManyRestartsParams := params.PodsHavingTooManyRestarts
		if tooManyRestartsParams == nil {
			tooManyRestartsParams = &PodsHavingTooManyRestarts{}
		}
		args := &removepodshavingtoomanyrestarts.RemovePodsHavingTooManyRestartsArgs{
			Namespaces:              v1alpha1NamespacesToInternal(params.Namespaces),
			LabelSelector:           params.LabelSelector,
			PodRestartThreshold:     tooManyRestartsParams.PodRestartThreshold,
			IncludingInitContainers: tooManyRestartsParams.IncludingInitContainers,
		}
		if err := removepodshavingtoomanyrestarts.ValidateRemovePodsHavingTooManyRestartsArgs(args); err != nil {
			klog.ErrorS(err, "unable to validate plugin arguments", "pluginName", removepodshavingtoomanyrestarts.PluginName)
			return nil, fmt.Errorf("strategy %q param validation failed: %v", removepodshavingtoomanyrestarts.PluginName, err)
		}
		return &api.PluginConfig{
			Name: removepodshavingtoomanyrestarts.PluginName,
			Args: args,
		}, nil
	},
	"PodLifeTime": func(params *StrategyParameters) (*api.PluginConfig, error) {
		podLifeTimeParams := params.PodLifeTime
		if podLifeTimeParams == nil {
			podLifeTimeParams = &PodLifeTime{}
		}

		var states []string
		if podLifeTimeParams.PodStatusPhases != nil {
			states = append(states, podLifeTimeParams.PodStatusPhases...)
		}
		if podLifeTimeParams.States != nil {
			states = append(states, podLifeTimeParams.States...)
		}

		args := &podlifetime.PodLifeTimeArgs{
			Namespaces:            v1alpha1NamespacesToInternal(params.Namespaces),
			LabelSelector:         params.LabelSelector,
			MaxPodLifeTimeSeconds: podLifeTimeParams.MaxPodLifeTimeSeconds,
			States:                states,
		}
		if err := podlifetime.ValidatePodLifeTimeArgs(args); err != nil {
			klog.ErrorS(err, "unable to validate plugin arguments", "pluginName", podlifetime.PluginName)
			return nil, fmt.Errorf("strategy %q param validation failed: %v", podlifetime.PluginName, err)
		}
		return &api.PluginConfig{
			Name: podlifetime.PluginName,
			Args: args,
		}, nil
	},
	"RemoveDuplicates": func(params *StrategyParameters) (*api.PluginConfig, error) {
		args := &removeduplicates.RemoveDuplicatesArgs{
			Namespaces: v1alpha1NamespacesToInternal(params.Namespaces),
		}
		if params.RemoveDuplicates != nil {
			args.ExcludeOwnerKinds = params.RemoveDuplicates.ExcludeOwnerKinds
		}
		if err := removeduplicates.ValidateRemoveDuplicatesArgs(args); err != nil {
			klog.ErrorS(err, "unable to validate plugin arguments", "pluginName", removeduplicates.PluginName)
			return nil, fmt.Errorf("strategy %q param validation failed: %v", removeduplicates.PluginName, err)
		}
		return &api.PluginConfig{
			Name: removeduplicates.PluginName,
			Args: args,
		}, nil
	},
	"RemovePodsViolatingTopologySpreadConstraint": func(params *StrategyParameters) (*api.PluginConfig, error) {
		constraints := []v1.UnsatisfiableConstraintAction{v1.DoNotSchedule}
		if params.IncludeSoftConstraints {
			constraints = append(constraints, v1.ScheduleAnyway)
		}
		args := &removepodsviolatingtopologyspreadconstraint.RemovePodsViolatingTopologySpreadConstraintArgs{
			Namespaces:             v1alpha1NamespacesToInternal(params.Namespaces),
			LabelSelector:          params.LabelSelector,
			Constraints:            constraints,
			TopologyBalanceNodeFit: utilpointer.Bool(true),
		}
		if err := removepodsviolatingtopologyspreadconstraint.ValidateRemovePodsViolatingTopologySpreadConstraintArgs(args); err != nil {
			klog.ErrorS(err, "unable to validate plugin arguments", "pluginName", removepodsviolatingtopologyspreadconstraint.PluginName)
			return nil, fmt.Errorf("strategy %q param validation failed: %v", removepodsviolatingtopologyspreadconstraint.PluginName, err)
		}
		return &api.PluginConfig{
			Name: removepodsviolatingtopologyspreadconstraint.PluginName,
			Args: args,
		}, nil
	},
	"HighNodeUtilization": func(params *StrategyParameters) (*api.PluginConfig, error) {
		if params.NodeResourceUtilizationThresholds == nil {
			params.NodeResourceUtilizationThresholds = &NodeResourceUtilizationThresholds{}
		}
		args := &nodeutilization.HighNodeUtilizationArgs{
			EvictableNamespaces: v1alpha1NamespacesToInternal(params.Namespaces),
			Thresholds:          v1alpha1ThresholdToInternal(params.NodeResourceUtilizationThresholds.Thresholds),
			NumberOfNodes:       params.NodeResourceUtilizationThresholds.NumberOfNodes,
		}
		if err := nodeutilization.ValidateHighNodeUtilizationArgs(args); err != nil {
			klog.ErrorS(err, "unable to validate plugin arguments", "pluginName", nodeutilization.HighNodeUtilizationPluginName)
			return nil, fmt.Errorf("strategy %q param validation failed: %v", nodeutilization.HighNodeUtilizationPluginName, err)
		}
		return &api.PluginConfig{
			Name: nodeutilization.HighNodeUtilizationPluginName,
			Args: args,
		}, nil
	},
	"LowNodeUtilization": func(params *StrategyParameters) (*api.PluginConfig, error) {
		if params.NodeResourceUtilizationThresholds == nil {
			params.NodeResourceUtilizationThresholds = &NodeResourceUtilizationThresholds{}
		}
		args := &nodeutilization.LowNodeUtilizationArgs{
			EvictableNamespaces:    v1alpha1NamespacesToInternal(params.Namespaces),
			Thresholds:             v1alpha1ThresholdToInternal(params.NodeResourceUtilizationThresholds.Thresholds),
			TargetThresholds:       v1alpha1ThresholdToInternal(params.NodeResourceUtilizationThresholds.TargetThresholds),
			UseDeviationThresholds: params.NodeResourceUtilizationThresholds.UseDeviationThresholds,
			NumberOfNodes:          params.NodeResourceUtilizationThresholds.NumberOfNodes,
		}

		if err := nodeutilization.ValidateLowNodeUtilizationArgs(args); err != nil {
			klog.ErrorS(err, "unable to validate plugin arguments", "pluginName", nodeutilization.LowNodeUtilizationPluginName)
			return nil, fmt.Errorf("strategy %q param validation failed: %v", nodeutilization.LowNodeUtilizationPluginName, err)
		}
		return &api.PluginConfig{
			Name: nodeutilization.LowNodeUtilizationPluginName,
			Args: args,
		}, nil
	},
}

Functions

func Convert_v1alpha1_DeschedulerPolicy_To_api_DeschedulerPolicy

func Convert_v1alpha1_DeschedulerPolicy_To_api_DeschedulerPolicy(in *DeschedulerPolicy, out *api.DeschedulerPolicy, s conversion.Scope) error

func Kind

func Kind(kind string) schema.GroupKind

Kind takes an unqualified kind and returns a Group qualified GroupKind

func RegisterConversions

func RegisterConversions(s *runtime.Scheme) error

Register Conversions

func RegisterDefaults

func RegisterDefaults(scheme *runtime.Scheme) error

RegisterDefaults adds defaulters functions to the given scheme. Public to allow building arbitrary schemes. All generated defaulters are covering - they call all nested defaulters.

func Resource

func Resource(resource string) schema.GroupResource

Resource takes an unqualified resource and returns a Group qualified GroupResource

func V1alpha1ToInternal added in v0.27.0

func V1alpha1ToInternal(
	deschedulerPolicy *DeschedulerPolicy,
	registry pluginregistry.Registry,
	out *api.DeschedulerPolicy,
	s conversion.Scope,
) error

Types

type DeschedulerPolicy

type DeschedulerPolicy struct {
	metav1.TypeMeta `json:",inline"`

	// Strategies
	Strategies StrategyList `json:"strategies,omitempty"`

	// NodeSelector for a set of nodes to operate over
	NodeSelector *string `json:"nodeSelector,omitempty"`

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

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

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

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

	// MaxNoOfPodsToEvictPerNode restricts maximum of pods to be evicted per node.
	MaxNoOfPodsToEvictPerNode *uint `json:"maxNoOfPodsToEvictPerNode,omitempty"`

	// MaxNoOfPodsToEvictPerNamespace restricts maximum of pods to be evicted per namespace.
	MaxNoOfPodsToEvictPerNamespace *uint `json:"maxNoOfPodsToEvictPerNamespace,omitempty"`
}

func (*DeschedulerPolicy) DeepCopy added in v0.4.0

func (in *DeschedulerPolicy) DeepCopy() *DeschedulerPolicy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeschedulerPolicy.

func (*DeschedulerPolicy) DeepCopyInto added in v0.4.0

func (in *DeschedulerPolicy) DeepCopyInto(out *DeschedulerPolicy)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*DeschedulerPolicy) DeepCopyObject added in v0.4.0

func (in *DeschedulerPolicy) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type DeschedulerStrategy

type DeschedulerStrategy struct {
	// Enabled or disabled
	Enabled bool `json:"enabled,omitempty"`

	// Weight
	Weight int `json:"weight,omitempty"`

	// Strategy parameters
	Params *StrategyParameters `json:"params,omitempty"`
}

func (*DeschedulerStrategy) DeepCopy added in v0.4.0

func (in *DeschedulerStrategy) DeepCopy() *DeschedulerStrategy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeschedulerStrategy.

func (*DeschedulerStrategy) DeepCopyInto added in v0.4.0

func (in *DeschedulerStrategy) DeepCopyInto(out *DeschedulerStrategy)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type FailedPods added in v0.22.0

type FailedPods struct {
	ExcludeOwnerKinds       []string `json:"excludeOwnerKinds,omitempty"`
	MinPodLifetimeSeconds   *uint    `json:"minPodLifetimeSeconds,omitempty"`
	Reasons                 []string `json:"reasons,omitempty"`
	IncludingInitContainers bool     `json:"includingInitContainers,omitempty"`
}

func (*FailedPods) DeepCopy added in v0.22.0

func (in *FailedPods) DeepCopy() *FailedPods

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FailedPods.

func (*FailedPods) DeepCopyInto added in v0.22.0

func (in *FailedPods) DeepCopyInto(out *FailedPods)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Namespaces added in v0.19.0

type Namespaces struct {
	Include []string `json:"include"`
	Exclude []string `json:"exclude"`
}

Namespaces carries a list of included/excluded namespaces for which a given strategy is applicable.

func (*Namespaces) DeepCopy added in v0.19.0

func (in *Namespaces) DeepCopy() *Namespaces

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Namespaces.

func (*Namespaces) DeepCopyInto added in v0.19.0

func (in *Namespaces) DeepCopyInto(out *Namespaces)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type NodeResourceUtilizationThresholds

type NodeResourceUtilizationThresholds struct {
	UseDeviationThresholds bool               `json:"useDeviationThresholds,omitempty"`
	Thresholds             ResourceThresholds `json:"thresholds,omitempty"`
	TargetThresholds       ResourceThresholds `json:"targetThresholds,omitempty"`
	NumberOfNodes          int                `json:"numberOfNodes,omitempty"`
}

func (*NodeResourceUtilizationThresholds) DeepCopy added in v0.4.0

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeResourceUtilizationThresholds.

func (*NodeResourceUtilizationThresholds) DeepCopyInto added in v0.4.0

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Percentage

type Percentage float64

type PodLifeTime added in v0.20.0

type PodLifeTime struct {
	MaxPodLifeTimeSeconds *uint    `json:"maxPodLifeTimeSeconds,omitempty"`
	States                []string `json:"states,omitempty"`

	// Deprecated: Use States instead.
	PodStatusPhases []string `json:"podStatusPhases,omitempty"`
}

func (*PodLifeTime) DeepCopy added in v0.20.0

func (in *PodLifeTime) DeepCopy() *PodLifeTime

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodLifeTime.

func (*PodLifeTime) DeepCopyInto added in v0.20.0

func (in *PodLifeTime) DeepCopyInto(out *PodLifeTime)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type PodsHavingTooManyRestarts added in v0.18.0

type PodsHavingTooManyRestarts struct {
	PodRestartThreshold     int32 `json:"podRestartThreshold,omitempty"`
	IncludingInitContainers bool  `json:"includingInitContainers,omitempty"`
}

func (*PodsHavingTooManyRestarts) DeepCopy added in v0.18.0

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodsHavingTooManyRestarts.

func (*PodsHavingTooManyRestarts) DeepCopyInto added in v0.18.0

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type RemoveDuplicates added in v0.18.0

type RemoveDuplicates struct {
	ExcludeOwnerKinds []string `json:"excludeOwnerKinds,omitempty"`
}

func (*RemoveDuplicates) DeepCopy added in v0.18.0

func (in *RemoveDuplicates) DeepCopy() *RemoveDuplicates

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoveDuplicates.

func (*RemoveDuplicates) DeepCopyInto added in v0.18.0

func (in *RemoveDuplicates) DeepCopyInto(out *RemoveDuplicates)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type ResourceThresholds

type ResourceThresholds map[v1.ResourceName]Percentage

func (ResourceThresholds) DeepCopy added in v0.10.0

func (in ResourceThresholds) DeepCopy() ResourceThresholds

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceThresholds.

func (ResourceThresholds) DeepCopyInto added in v0.10.0

func (in ResourceThresholds) DeepCopyInto(out *ResourceThresholds)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type StrategyList

type StrategyList map[StrategyName]DeschedulerStrategy

func (StrategyList) DeepCopy added in v0.10.0

func (in StrategyList) DeepCopy() StrategyList

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StrategyList.

func (StrategyList) DeepCopyInto added in v0.10.0

func (in StrategyList) DeepCopyInto(out *StrategyList)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type StrategyName

type StrategyName string

type StrategyParameters

type StrategyParameters struct {
	NodeResourceUtilizationThresholds *NodeResourceUtilizationThresholds `json:"nodeResourceUtilizationThresholds,omitempty"`
	NodeAffinityType                  []string                           `json:"nodeAffinityType,omitempty"`
	PodsHavingTooManyRestarts         *PodsHavingTooManyRestarts         `json:"podsHavingTooManyRestarts,omitempty"`
	PodLifeTime                       *PodLifeTime                       `json:"podLifeTime,omitempty"`
	RemoveDuplicates                  *RemoveDuplicates                  `json:"removeDuplicates,omitempty"`
	FailedPods                        *FailedPods                        `json:"failedPods,omitempty"`
	IncludeSoftConstraints            bool                               `json:"includeSoftConstraints"`
	Namespaces                        *Namespaces                        `json:"namespaces"`
	ThresholdPriority                 *int32                             `json:"thresholdPriority"`
	ThresholdPriorityClassName        string                             `json:"thresholdPriorityClassName"`
	LabelSelector                     *metav1.LabelSelector              `json:"labelSelector"`
	NodeFit                           bool                               `json:"nodeFit"`
	IncludePreferNoSchedule           bool                               `json:"includePreferNoSchedule"`
	ExcludedTaints                    []string                           `json:"excludedTaints,omitempty"`
}

Besides Namespaces ThresholdPriority and ThresholdPriorityClassName only one of its members may be specified

func (*StrategyParameters) DeepCopy added in v0.4.0

func (in *StrategyParameters) DeepCopy() *StrategyParameters

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StrategyParameters.

func (*StrategyParameters) DeepCopyInto added in v0.4.0

func (in *StrategyParameters) DeepCopyInto(out *StrategyParameters)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL