Skip to content

Commit 5ce86e5

Browse files
authored
Merge branch 'kubernetes-sigs:master' into vseva/1597
2 parents 2b40fd4 + 0b3c022 commit 5ce86e5

File tree

12 files changed

+122
-16
lines changed

12 files changed

+122
-16
lines changed

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,16 @@ The Descheduler Policy is configurable and includes default strategy plugins tha
118118

119119
These are top level keys in the Descheduler Policy that you can use to configure all evictions.
120120

121-
| Name |type| Default Value | Description |
122-
|------|----|---------------|-------------|
123-
| `nodeSelector` |`string`| `nil` | limiting the nodes which are processed. Only used when `nodeFit`=`true` and only by the PreEvictionFilter Extension Point |
124-
| `maxNoOfPodsToEvictPerNode` |`int`| `nil` | maximum number of pods evicted from each node (summed through all strategies) |
125-
| `maxNoOfPodsToEvictPerNamespace` |`int`| `nil` | maximum number of pods evicted from each namespace (summed through all strategies) |
126-
| `maxNoOfPodsToEvictTotal` |`int`| `nil` | maximum number of pods evicted per rescheduling cycle (summed through all strategies) |
127-
| `metricsCollector` |`object`| `nil` | configures collection of metrics for actual resource utilization |
128-
| `metricsCollector.enabled` |`bool`| `false` | enables kubernetes [metrics server](https://kubernetes-sigs.github.io/metrics-server/) collection |
121+
| Name | type | Default Value | Description |
122+
|------------------------------------|----------|---------------|----------------------------------------------------------------------------------------------------------------------------|
123+
| `nodeSelector` | `string` | `nil` | Limiting the nodes which are processed. Only used when `nodeFit`=`true` and only by the PreEvictionFilter Extension Point. |
124+
| `maxNoOfPodsToEvictPerNode` | `int` | `nil` | Maximum number of pods evicted from each node (summed through all strategies). |
125+
| `maxNoOfPodsToEvictPerNamespace` | `int` | `nil` | Maximum number of pods evicted from each namespace (summed through all strategies). |
126+
| `maxNoOfPodsToEvictTotal` | `int` | `nil` | Maximum number of pods evicted per rescheduling cycle (summed through all strategies). |
127+
| `metricsCollector` | `object` | `nil` | Configures collection of metrics for actual resource utilization. |
128+
| `metricsCollector.enabled` | `bool` | `false` | Enables Kubernetes [Metrics Server](https://kubernetes-sigs.github.io/metrics-server/) collection. |
129+
| `evictionFailureEventNotification` | `bool` | `false` | Enables eviction failure event notification. |
130+
| `gracePeriodSeconds` | `int` | `0` | The duration in seconds before the object should be deleted. The value zero indicates delete immediately. |
129131

130132
### Evictor Plugin configuration (Default Evictor)
131133

@@ -160,6 +162,7 @@ nodeSelector: "node=node1" # you don't need to set this, if not set all will be
160162
maxNoOfPodsToEvictPerNode: 5000 # you don't need to set this, unlimited if not set
161163
maxNoOfPodsToEvictPerNamespace: 5000 # you don't need to set this, unlimited if not set
162164
maxNoOfPodsToEvictTotal: 5000 # you don't need to set this, unlimited if not set
165+
gracePeriodSeconds: 60 # you don't need to set this, 0 if not set
163166
metricsCollector:
164167
enabled: true # you don't need to set this, metrics are not collected if not set
165168
profiles:

charts/descheduler/templates/clusterrole.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ rules:
2424
- apiGroups: ["scheduling.k8s.io"]
2525
resources: ["priorityclasses"]
2626
verbs: ["get", "watch", "list"]
27+
- apiGroups: ["policy"]
28+
resources: ["poddisruptionbudgets"]
29+
verbs: ["get", "watch", "list"]
2730
{{- if .Values.leaderElection.enabled }}
2831
- apiGroups: ["coordination.k8s.io"]
2932
resources: ["leases"]

pkg/api/types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ type DeschedulerPolicy struct {
4848

4949
// MetricsCollector configures collection of metrics about actual resource utilization
5050
MetricsCollector MetricsCollector
51+
52+
// GracePeriodSeconds The duration in seconds before the object should be deleted. Value must be non-negative integer.
53+
// The value zero indicates delete immediately. If this value is nil, the default grace period for the
54+
// specified type will be used.
55+
// Defaults to a per object value if not specified. zero means delete immediately.
56+
GracePeriodSeconds *int64
5157
}
5258

5359
// Namespaces carries a list of included/excluded namespaces

pkg/api/v1alpha2/types.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,16 @@ type DeschedulerPolicy struct {
4343

4444
// EvictionFailureEventNotification should be set to true to enable eviction failure event notification.
4545
// Default is false.
46-
EvictionFailureEventNotification *bool
46+
EvictionFailureEventNotification *bool `json:"evictionFailureEventNotification,omitempty"`
4747

4848
// MetricsCollector configures collection of metrics for actual resource utilization
4949
MetricsCollector MetricsCollector `json:"metricsCollector,omitempty"`
50+
51+
// GracePeriodSeconds The duration in seconds before the object should be deleted. Value must be non-negative integer.
52+
// The value zero indicates delete immediately. If this value is nil, the default grace period for the
53+
// specified type will be used.
54+
// Defaults to a per object value if not specified. zero means delete immediately.
55+
GracePeriodSeconds *int64 `json:"gracePeriodSeconds,omitempty"`
5056
}
5157

5258
type DeschedulerProfile struct {

pkg/api/v1alpha2/zz_generated.conversion.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/api/v1alpha2/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/api/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/descheduler/descheduler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ func newDescheduler(ctx context.Context, rs *options.DeschedulerServer, deschedu
157157
WithMaxPodsToEvictPerNamespace(deschedulerPolicy.MaxNoOfPodsToEvictPerNamespace).
158158
WithMaxPodsToEvictTotal(deschedulerPolicy.MaxNoOfPodsToEvictTotal).
159159
WithEvictionFailureEventNotification(deschedulerPolicy.EvictionFailureEventNotification).
160+
WithGracePeriodSeconds(deschedulerPolicy.GracePeriodSeconds).
160161
WithDryRun(rs.DryRun).
161162
WithMetricsEnabled(!rs.DisableMetrics),
162163
)

pkg/descheduler/evictions/evictions.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ type PodEvictor struct {
214214
maxPodsToEvictPerNode *uint
215215
maxPodsToEvictPerNamespace *uint
216216
maxPodsToEvictTotal *uint
217+
gracePeriodSeconds *int64
217218
nodePodCount nodePodEvictedCount
218219
namespacePodCount namespacePodEvictCount
219220
totalPodCount uint
@@ -247,6 +248,7 @@ func NewPodEvictor(
247248
maxPodsToEvictPerNode: options.maxPodsToEvictPerNode,
248249
maxPodsToEvictPerNamespace: options.maxPodsToEvictPerNamespace,
249250
maxPodsToEvictTotal: options.maxPodsToEvictTotal,
251+
gracePeriodSeconds: options.gracePeriodSeconds,
250252
metricsEnabled: options.metricsEnabled,
251253
nodePodCount: make(nodePodEvictedCount),
252254
namespacePodCount: make(namespacePodEvictCount),
@@ -563,7 +565,9 @@ func (pe *PodEvictor) EvictPod(ctx context.Context, pod *v1.Pod, opts EvictOptio
563565

564566
// return (ignore, err)
565567
func (pe *PodEvictor) evictPod(ctx context.Context, pod *v1.Pod) (bool, error) {
566-
deleteOptions := &metav1.DeleteOptions{}
568+
deleteOptions := &metav1.DeleteOptions{
569+
GracePeriodSeconds: pe.gracePeriodSeconds,
570+
}
567571
// GracePeriodSeconds ?
568572
eviction := &policy.Eviction{
569573
TypeMeta: metav1.TypeMeta{

pkg/descheduler/evictions/options.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type Options struct {
1212
maxPodsToEvictTotal *uint
1313
evictionFailureEventNotification bool
1414
metricsEnabled bool
15+
gracePeriodSeconds *int64
1516
}
1617

1718
// NewOptions returns an Options with default values.
@@ -46,6 +47,11 @@ func (o *Options) WithMaxPodsToEvictTotal(maxPodsToEvictTotal *uint) *Options {
4647
return o
4748
}
4849

50+
func (o *Options) WithGracePeriodSeconds(gracePeriodSeconds *int64) *Options {
51+
o.gracePeriodSeconds = gracePeriodSeconds
52+
return o
53+
}
54+
4955
func (o *Options) WithMetricsEnabled(metricsEnabled bool) *Options {
5056
o.metricsEnabled = metricsEnabled
5157
return o

0 commit comments

Comments
 (0)