Skip to content

Commit 596b1f9

Browse files
committed
Add TerminatedPodGcThreshold to control plane component config
Adds support for kubeControllerManagerConfig.podGcControllerConfig. terminatedPodGcThreshold, wiring it through the create path (CloudFormation via the vendored goformation structs) and the update path (eksctl utils update-control-plane-component-config, via the EKS SDK). The kube-controller-manager converters are restructured so the pod GC and horizontal pod autoscaler sub-configs are independent: either or both may be set, and setting one no longer drops the other. Signed-off-by: Chithresh Azad <chithres@amazon.com>
1 parent 11249ee commit 596b1f9

10 files changed

Lines changed: 243 additions & 44 deletions

pkg/apis/eksctl.io/v1alpha5/assets/schema.json

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1656,10 +1656,16 @@
16561656
"$ref": "#/definitions/HorizontalPodAutoscalerControllerConfig",
16571657
"description": "specifies the horizontal pod autoscaler controller configuration.",
16581658
"x-intellij-html-description": "specifies the horizontal pod autoscaler controller configuration."
1659+
},
1660+
"podGCControllerConfig": {
1661+
"$ref": "#/definitions/PodGCControllerConfig",
1662+
"description": "specifies the pod garbage collector controller configuration.",
1663+
"x-intellij-html-description": "specifies the pod garbage collector controller configuration."
16591664
}
16601665
},
16611666
"preferredOrder": [
1662-
"horizontalPodAutoscalerControllerConfig"
1667+
"horizontalPodAutoscalerControllerConfig",
1668+
"podGCControllerConfig"
16631669
],
16641670
"additionalProperties": false,
16651671
"description": "holds the kube-controller-manager configuration.",
@@ -2981,6 +2987,21 @@
29812987
"description": "specifies placement group information",
29822988
"x-intellij-html-description": "specifies placement group information"
29832989
},
2990+
"PodGCControllerConfig": {
2991+
"properties": {
2992+
"terminatedPodGCThreshold": {
2993+
"type": "integer",
2994+
"description": "specifies the number of terminated pods that can exist before the pod garbage collector starts deleting terminated pods.",
2995+
"x-intellij-html-description": "specifies the number of terminated pods that can exist before the pod garbage collector starts deleting terminated pods."
2996+
}
2997+
},
2998+
"preferredOrder": [
2999+
"terminatedPodGCThreshold"
3000+
],
3001+
"additionalProperties": false,
3002+
"description": "holds the pod garbage collector controller configuration.",
3003+
"x-intellij-html-description": "holds the pod garbage collector controller configuration."
3004+
},
29843005
"PodIdentityAssociation": {
29853006
"properties": {
29863007
"createServiceAccount": {

pkg/apis/eksctl.io/v1alpha5/types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,10 @@ type KubeControllerManagerConfig struct {
12221222
// controller configuration.
12231223
// +optional
12241224
HorizontalPodAutoscalerControllerConfig *HorizontalPodAutoscalerControllerConfig `json:"horizontalPodAutoscalerControllerConfig,omitempty"`
1225+
1226+
// PodGCControllerConfig specifies the pod garbage collector controller configuration.
1227+
// +optional
1228+
PodGCControllerConfig *PodGCControllerConfig `json:"podGCControllerConfig,omitempty"`
12251229
}
12261230

12271231
// HorizontalPodAutoscalerControllerConfig holds the horizontal pod autoscaler controller configuration.
@@ -1232,6 +1236,14 @@ type HorizontalPodAutoscalerControllerConfig struct {
12321236
HorizontalPodAutoscalerSyncPeriod *string `json:"horizontalPodAutoscalerSyncPeriod,omitempty"`
12331237
}
12341238

1239+
// PodGCControllerConfig holds the pod garbage collector controller configuration.
1240+
type PodGCControllerConfig struct {
1241+
// TerminatedPodGCThreshold specifies the number of terminated pods that can exist
1242+
// before the pod garbage collector starts deleting terminated pods.
1243+
// +optional
1244+
TerminatedPodGCThreshold *int `json:"terminatedPodGCThreshold,omitempty"`
1245+
}
1246+
12351247
// OutpostInfo describes the Outpost info.
12361248
type OutpostInfo interface {
12371249
// IsControlPlaneOnOutposts returns true if the control plane is on Outposts.

pkg/apis/eksctl.io/v1alpha5/zz_generated.deepcopy.go

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

pkg/cfn/builder/cluster.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -706,16 +706,25 @@ func makeKubeSchedulerConfig(config *api.KubeSchedulerConfig) *gfneks.Cluster_Ku
706706
// CloudFormation representation. It returns nil if no values are set, so that the property
707707
// is omitted from the template entirely.
708708
func makeKubeControllerManagerConfig(config *api.KubeControllerManagerConfig) *gfneks.Cluster_KubeControllerManagerConfig {
709-
if config == nil || config.HorizontalPodAutoscalerControllerConfig == nil {
710-
return nil
711-
}
712-
hpaConfig := config.HorizontalPodAutoscalerControllerConfig
713-
if hpaConfig.HorizontalPodAutoscalerSyncPeriod == nil {
709+
if config == nil {
714710
return nil
715711
}
716-
return &gfneks.Cluster_KubeControllerManagerConfig{
717-
HorizontalPodAutoscalerControllerConfig: &gfneks.Cluster_HorizontalPodAutoscalerControllerConfig{
712+
result := &gfneks.Cluster_KubeControllerManagerConfig{}
713+
set := false
714+
if hpaConfig := config.HorizontalPodAutoscalerControllerConfig; hpaConfig != nil && hpaConfig.HorizontalPodAutoscalerSyncPeriod != nil {
715+
result.HorizontalPodAutoscalerControllerConfig = &gfneks.Cluster_HorizontalPodAutoscalerControllerConfig{
718716
HorizontalPodAutoscalerSyncPeriod: gfnt.NewString(*hpaConfig.HorizontalPodAutoscalerSyncPeriod),
719-
},
717+
}
718+
set = true
719+
}
720+
if podGCConfig := config.PodGCControllerConfig; podGCConfig != nil && podGCConfig.TerminatedPodGCThreshold != nil {
721+
result.PodGcControllerConfig = &gfneks.Cluster_PodGcControllerConfig{
722+
TerminatedPodGcThreshold: gfnt.NewInteger(*podGCConfig.TerminatedPodGCThreshold),
723+
}
724+
set = true
725+
}
726+
if !set {
727+
return nil
720728
}
729+
return result
721730
}

pkg/cfn/builder/cluster_component_config_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,42 @@ var _ = Describe("control plane component config template properties", func() {
282282
},
283283
},
284284
}),
285+
Entry("empty pod GC config is omitted", entry{
286+
config: &api.KubeControllerManagerConfig{
287+
PodGCControllerConfig: &api.PodGCControllerConfig{},
288+
},
289+
expected: nil,
290+
}),
291+
Entry("terminated pod GC threshold set", entry{
292+
config: &api.KubeControllerManagerConfig{
293+
PodGCControllerConfig: &api.PodGCControllerConfig{
294+
TerminatedPodGCThreshold: aws.Int(12000),
295+
},
296+
},
297+
expected: &gfneks.Cluster_KubeControllerManagerConfig{
298+
PodGcControllerConfig: &gfneks.Cluster_PodGcControllerConfig{
299+
TerminatedPodGcThreshold: gfnt.NewInteger(12000),
300+
},
301+
},
302+
}),
303+
Entry("both sync period and terminated pod GC threshold set", entry{
304+
config: &api.KubeControllerManagerConfig{
305+
HorizontalPodAutoscalerControllerConfig: &api.HorizontalPodAutoscalerControllerConfig{
306+
HorizontalPodAutoscalerSyncPeriod: aws.String("15s"),
307+
},
308+
PodGCControllerConfig: &api.PodGCControllerConfig{
309+
TerminatedPodGCThreshold: aws.Int(12000),
310+
},
311+
},
312+
expected: &gfneks.Cluster_KubeControllerManagerConfig{
313+
HorizontalPodAutoscalerControllerConfig: &gfneks.Cluster_HorizontalPodAutoscalerControllerConfig{
314+
HorizontalPodAutoscalerSyncPeriod: gfnt.NewString("15s"),
315+
},
316+
PodGcControllerConfig: &gfneks.Cluster_PodGcControllerConfig{
317+
TerminatedPodGcThreshold: gfnt.NewInteger(12000),
318+
},
319+
},
320+
}),
285321
)
286322
})
287323
})

pkg/ctl/utils/update_control_plane_component_config.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,25 @@ func makeKubeSchedulerConfigRequest(config *api.KubeSchedulerConfig) *ekstypes.K
151151
// component is omitted from the request entirely and left unchanged.
152152
// It mirrors makeKubeControllerManagerConfig in pkg/cfn/builder/cluster.go.
153153
func makeKubeControllerManagerConfigRequest(config *api.KubeControllerManagerConfig) *ekstypes.KubeControllerManagerConfigRequest {
154-
if config == nil || config.HorizontalPodAutoscalerControllerConfig == nil {
155-
return nil
156-
}
157-
hpaConfig := config.HorizontalPodAutoscalerControllerConfig
158-
if hpaConfig.HorizontalPodAutoscalerSyncPeriod == nil {
154+
if config == nil {
159155
return nil
160156
}
161-
return &ekstypes.KubeControllerManagerConfigRequest{
162-
HorizontalPodAutoscalerControllerConfig: &ekstypes.HorizontalPodAutoscalerControllerConfigRequest{
157+
result := &ekstypes.KubeControllerManagerConfigRequest{}
158+
set := false
159+
if hpaConfig := config.HorizontalPodAutoscalerControllerConfig; hpaConfig != nil && hpaConfig.HorizontalPodAutoscalerSyncPeriod != nil {
160+
result.HorizontalPodAutoscalerControllerConfig = &ekstypes.HorizontalPodAutoscalerControllerConfigRequest{
163161
HorizontalPodAutoscalerSyncPeriod: hpaConfig.HorizontalPodAutoscalerSyncPeriod,
164-
},
162+
}
163+
set = true
164+
}
165+
if podGCConfig := config.PodGCControllerConfig; podGCConfig != nil && podGCConfig.TerminatedPodGCThreshold != nil {
166+
result.PodGcControllerConfig = &ekstypes.PodGcControllerConfigRequest{
167+
TerminatedPodGcThreshold: aws.Int32(int32(*podGCConfig.TerminatedPodGCThreshold)),
168+
}
169+
set = true
170+
}
171+
if !set {
172+
return nil
165173
}
174+
return result
166175
}

pkg/ctl/utils/update_control_plane_component_config_request_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,42 @@ var _ = Describe("control plane component config update requests", func() {
250250
},
251251
},
252252
}),
253+
Entry("empty pod GC config is not sent", entry{
254+
config: &api.KubeControllerManagerConfig{
255+
PodGCControllerConfig: &api.PodGCControllerConfig{},
256+
},
257+
expected: nil,
258+
}),
259+
Entry("terminated pod GC threshold set", entry{
260+
config: &api.KubeControllerManagerConfig{
261+
PodGCControllerConfig: &api.PodGCControllerConfig{
262+
TerminatedPodGCThreshold: aws.Int(12000),
263+
},
264+
},
265+
expected: &ekstypes.KubeControllerManagerConfigRequest{
266+
PodGcControllerConfig: &ekstypes.PodGcControllerConfigRequest{
267+
TerminatedPodGcThreshold: aws.Int32(12000),
268+
},
269+
},
270+
}),
271+
Entry("both sync period and terminated pod GC threshold set", entry{
272+
config: &api.KubeControllerManagerConfig{
273+
HorizontalPodAutoscalerControllerConfig: &api.HorizontalPodAutoscalerControllerConfig{
274+
HorizontalPodAutoscalerSyncPeriod: aws.String("15s"),
275+
},
276+
PodGCControllerConfig: &api.PodGCControllerConfig{
277+
TerminatedPodGCThreshold: aws.Int(12000),
278+
},
279+
},
280+
expected: &ekstypes.KubeControllerManagerConfigRequest{
281+
HorizontalPodAutoscalerControllerConfig: &ekstypes.HorizontalPodAutoscalerControllerConfigRequest{
282+
HorizontalPodAutoscalerSyncPeriod: aws.String("15s"),
283+
},
284+
PodGcControllerConfig: &ekstypes.PodGcControllerConfigRequest{
285+
TerminatedPodGcThreshold: aws.Int32(12000),
286+
},
287+
},
288+
}),
253289
)
254290
})
255291
})

pkg/goformation/cloudformation/eks/aws-eks-cluster_kubecontrollermanagerconfig.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ type Cluster_KubeControllerManagerConfig struct {
1313
// See: https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-eks-cluster-kubecontrollermanagerconfig.html#cfn-eks-cluster-kubecontrollermanagerconfig-horizontalpodautoscalercontrollerconfig
1414
HorizontalPodAutoscalerControllerConfig *Cluster_HorizontalPodAutoscalerControllerConfig `json:"HorizontalPodAutoscalerControllerConfig,omitempty"`
1515

16+
// PodGcControllerConfig AWS CloudFormation Property
17+
// Required: false
18+
// See: https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-eks-cluster-kubecontrollermanagerconfig.html#cfn-eks-cluster-kubecontrollermanagerconfig-podgccontrollerconfig
19+
PodGcControllerConfig *Cluster_PodGcControllerConfig `json:"PodGcControllerConfig,omitempty"`
20+
1621
// AWSCloudFormationDeletionPolicy represents a CloudFormation DeletionPolicy
1722
AWSCloudFormationDeletionPolicy policies.DeletionPolicy `json:"-"`
1823

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package eks
2+
3+
import (
4+
"github.com/weaveworks/eksctl/pkg/goformation/cloudformation/policies"
5+
"github.com/weaveworks/eksctl/pkg/goformation/cloudformation/types"
6+
)
7+
8+
// Cluster_PodGcControllerConfig AWS CloudFormation Resource (AWS::EKS::Cluster.PodGcControllerConfig)
9+
// See: https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-eks-cluster-podgccontrollerconfig.html
10+
type Cluster_PodGcControllerConfig struct {
11+
12+
// TerminatedPodGcThreshold AWS CloudFormation Property
13+
// Required: false
14+
// See: https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-eks-cluster-podgccontrollerconfig.html#cfn-eks-cluster-podgccontrollerconfig-terminatedpodgcthreshold
15+
TerminatedPodGcThreshold *types.Value `json:"TerminatedPodGcThreshold,omitempty"`
16+
17+
// AWSCloudFormationDeletionPolicy represents a CloudFormation DeletionPolicy
18+
AWSCloudFormationDeletionPolicy policies.DeletionPolicy `json:"-"`
19+
20+
// AWSCloudFormationUpdateReplacePolicy represents a CloudFormation UpdateReplacePolicy
21+
AWSCloudFormationUpdateReplacePolicy policies.UpdateReplacePolicy `json:"-"`
22+
23+
// AWSCloudFormationDependsOn stores the logical ID of the resources to be created before this resource
24+
AWSCloudFormationDependsOn []string `json:"-"`
25+
26+
// AWSCloudFormationMetadata stores structured data associated with this resource
27+
AWSCloudFormationMetadata map[string]interface{} `json:"-"`
28+
29+
// AWSCloudFormationCondition stores the logical ID of the condition that must be satisfied for this resource to be created
30+
AWSCloudFormationCondition string `json:"-"`
31+
}
32+
33+
// AWSCloudFormationType returns the AWS CloudFormation resource type
34+
func (r *Cluster_PodGcControllerConfig) AWSCloudFormationType() string {
35+
return "AWS::EKS::Cluster.PodGcControllerConfig"
36+
}

0 commit comments

Comments
 (0)