Skip to content
Open
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
23 changes: 22 additions & 1 deletion pkg/apis/eksctl.io/v1alpha5/assets/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1656,10 +1656,16 @@
"$ref": "#/definitions/HorizontalPodAutoscalerControllerConfig",
"description": "specifies the horizontal pod autoscaler controller configuration.",
"x-intellij-html-description": "specifies the horizontal pod autoscaler controller configuration."
},
"podGCControllerConfig": {
"$ref": "#/definitions/PodGCControllerConfig",
"description": "specifies the pod garbage collector controller configuration.",
"x-intellij-html-description": "specifies the pod garbage collector controller configuration."
}
},
"preferredOrder": [
"horizontalPodAutoscalerControllerConfig"
"horizontalPodAutoscalerControllerConfig",
"podGCControllerConfig"
],
"additionalProperties": false,
"description": "holds the kube-controller-manager configuration.",
Expand Down Expand Up @@ -2981,6 +2987,21 @@
"description": "specifies placement group information",
"x-intellij-html-description": "specifies placement group information"
},
"PodGCControllerConfig": {
"properties": {
"terminatedPodGCThreshold": {
"type": "integer",
"description": "specifies the number of terminated pods that can exist before the pod garbage collector starts deleting terminated pods.",
"x-intellij-html-description": "specifies the number of terminated pods that can exist before the pod garbage collector starts deleting terminated pods."
}
},
"preferredOrder": [
"terminatedPodGCThreshold"
],
"additionalProperties": false,
"description": "holds the pod garbage collector controller configuration.",
"x-intellij-html-description": "holds the pod garbage collector controller configuration."
},
"PodIdentityAssociation": {
"properties": {
"createServiceAccount": {
Expand Down
12 changes: 12 additions & 0 deletions pkg/apis/eksctl.io/v1alpha5/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,10 @@ type KubeControllerManagerConfig struct {
// controller configuration.
// +optional
HorizontalPodAutoscalerControllerConfig *HorizontalPodAutoscalerControllerConfig `json:"horizontalPodAutoscalerControllerConfig,omitempty"`

// PodGCControllerConfig specifies the pod garbage collector controller configuration.
// +optional
PodGCControllerConfig *PodGCControllerConfig `json:"podGCControllerConfig,omitempty"`
}

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

// PodGCControllerConfig holds the pod garbage collector controller configuration.
type PodGCControllerConfig struct {
// TerminatedPodGCThreshold specifies the number of terminated pods that can exist
// before the pod garbage collector starts deleting terminated pods.
// +optional
TerminatedPodGCThreshold *int `json:"terminatedPodGCThreshold,omitempty"`
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should follow the Go initialism pattern for these (podGCControllerConfig / terminatedPodGCThreshold / etc)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. Will fix this.


// OutpostInfo describes the Outpost info.
type OutpostInfo interface {
// IsControlPlaneOnOutposts returns true if the control plane is on Outposts.
Expand Down
78 changes: 52 additions & 26 deletions pkg/apis/eksctl.io/v1alpha5/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 17 additions & 8 deletions pkg/cfn/builder/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,16 +706,25 @@ func makeKubeSchedulerConfig(config *api.KubeSchedulerConfig) *gfneks.Cluster_Ku
// CloudFormation representation. It returns nil if no values are set, so that the property
// is omitted from the template entirely.
func makeKubeControllerManagerConfig(config *api.KubeControllerManagerConfig) *gfneks.Cluster_KubeControllerManagerConfig {
if config == nil || config.HorizontalPodAutoscalerControllerConfig == nil {
return nil
}
hpaConfig := config.HorizontalPodAutoscalerControllerConfig
if hpaConfig.HorizontalPodAutoscalerSyncPeriod == nil {
if config == nil {
return nil
}
return &gfneks.Cluster_KubeControllerManagerConfig{
HorizontalPodAutoscalerControllerConfig: &gfneks.Cluster_HorizontalPodAutoscalerControllerConfig{
result := &gfneks.Cluster_KubeControllerManagerConfig{}
set := false
if hpaConfig := config.HorizontalPodAutoscalerControllerConfig; hpaConfig != nil && hpaConfig.HorizontalPodAutoscalerSyncPeriod != nil {
result.HorizontalPodAutoscalerControllerConfig = &gfneks.Cluster_HorizontalPodAutoscalerControllerConfig{
HorizontalPodAutoscalerSyncPeriod: gfnt.NewString(*hpaConfig.HorizontalPodAutoscalerSyncPeriod),
},
}
set = true
}
if podGCConfig := config.PodGCControllerConfig; podGCConfig != nil && podGCConfig.TerminatedPodGCThreshold != nil {
result.PodGcControllerConfig = &gfneks.Cluster_PodGcControllerConfig{
TerminatedPodGcThreshold: gfnt.NewInteger(*podGCConfig.TerminatedPodGCThreshold),
}
set = true
}
if !set {
return nil
}
return result
}
36 changes: 36 additions & 0 deletions pkg/cfn/builder/cluster_component_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,42 @@ var _ = Describe("control plane component config template properties", func() {
},
},
}),
Entry("empty pod GC config is omitted", entry{
config: &api.KubeControllerManagerConfig{
PodGCControllerConfig: &api.PodGCControllerConfig{},
},
expected: nil,
}),
Entry("terminated pod GC threshold set", entry{
config: &api.KubeControllerManagerConfig{
PodGCControllerConfig: &api.PodGCControllerConfig{
TerminatedPodGCThreshold: aws.Int(12000),
},
},
expected: &gfneks.Cluster_KubeControllerManagerConfig{
PodGcControllerConfig: &gfneks.Cluster_PodGcControllerConfig{
TerminatedPodGcThreshold: gfnt.NewInteger(12000),
},
},
}),
Entry("both sync period and terminated pod GC threshold set", entry{
config: &api.KubeControllerManagerConfig{
HorizontalPodAutoscalerControllerConfig: &api.HorizontalPodAutoscalerControllerConfig{
HorizontalPodAutoscalerSyncPeriod: aws.String("15s"),
},
PodGCControllerConfig: &api.PodGCControllerConfig{
TerminatedPodGCThreshold: aws.Int(12000),
},
},
expected: &gfneks.Cluster_KubeControllerManagerConfig{
HorizontalPodAutoscalerControllerConfig: &gfneks.Cluster_HorizontalPodAutoscalerControllerConfig{
HorizontalPodAutoscalerSyncPeriod: gfnt.NewString("15s"),
},
PodGcControllerConfig: &gfneks.Cluster_PodGcControllerConfig{
TerminatedPodGcThreshold: gfnt.NewInteger(12000),
},
},
}),
)
})
})
25 changes: 17 additions & 8 deletions pkg/ctl/utils/update_control_plane_component_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,25 @@ func makeKubeSchedulerConfigRequest(config *api.KubeSchedulerConfig) *ekstypes.K
// component is omitted from the request entirely and left unchanged.
// It mirrors makeKubeControllerManagerConfig in pkg/cfn/builder/cluster.go.
func makeKubeControllerManagerConfigRequest(config *api.KubeControllerManagerConfig) *ekstypes.KubeControllerManagerConfigRequest {
if config == nil || config.HorizontalPodAutoscalerControllerConfig == nil {
return nil
}
hpaConfig := config.HorizontalPodAutoscalerControllerConfig
if hpaConfig.HorizontalPodAutoscalerSyncPeriod == nil {
if config == nil {
return nil
}
return &ekstypes.KubeControllerManagerConfigRequest{
HorizontalPodAutoscalerControllerConfig: &ekstypes.HorizontalPodAutoscalerControllerConfigRequest{
result := &ekstypes.KubeControllerManagerConfigRequest{}
set := false
if hpaConfig := config.HorizontalPodAutoscalerControllerConfig; hpaConfig != nil && hpaConfig.HorizontalPodAutoscalerSyncPeriod != nil {
result.HorizontalPodAutoscalerControllerConfig = &ekstypes.HorizontalPodAutoscalerControllerConfigRequest{
HorizontalPodAutoscalerSyncPeriod: hpaConfig.HorizontalPodAutoscalerSyncPeriod,
},
}
set = true
}
if podGCConfig := config.PodGCControllerConfig; podGCConfig != nil && podGCConfig.TerminatedPodGCThreshold != nil {
result.PodGcControllerConfig = &ekstypes.PodGcControllerConfigRequest{
TerminatedPodGcThreshold: aws.Int32(int32(*podGCConfig.TerminatedPodGCThreshold)),
}
set = true
}
if !set {
return nil
}
return result
}
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,42 @@ var _ = Describe("control plane component config update requests", func() {
},
},
}),
Entry("empty pod GC config is not sent", entry{
config: &api.KubeControllerManagerConfig{
PodGCControllerConfig: &api.PodGCControllerConfig{},
},
expected: nil,
}),
Entry("terminated pod GC threshold set", entry{
config: &api.KubeControllerManagerConfig{
PodGCControllerConfig: &api.PodGCControllerConfig{
TerminatedPodGCThreshold: aws.Int(12000),
},
},
expected: &ekstypes.KubeControllerManagerConfigRequest{
PodGcControllerConfig: &ekstypes.PodGcControllerConfigRequest{
TerminatedPodGcThreshold: aws.Int32(12000),
},
},
}),
Entry("both sync period and terminated pod GC threshold set", entry{
config: &api.KubeControllerManagerConfig{
HorizontalPodAutoscalerControllerConfig: &api.HorizontalPodAutoscalerControllerConfig{
HorizontalPodAutoscalerSyncPeriod: aws.String("15s"),
},
PodGCControllerConfig: &api.PodGCControllerConfig{
TerminatedPodGCThreshold: aws.Int(12000),
},
},
expected: &ekstypes.KubeControllerManagerConfigRequest{
HorizontalPodAutoscalerControllerConfig: &ekstypes.HorizontalPodAutoscalerControllerConfigRequest{
HorizontalPodAutoscalerSyncPeriod: aws.String("15s"),
},
PodGcControllerConfig: &ekstypes.PodGcControllerConfigRequest{
TerminatedPodGcThreshold: aws.Int32(12000),
},
},
}),
)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ type Cluster_KubeControllerManagerConfig struct {
// See: https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-eks-cluster-kubecontrollermanagerconfig.html#cfn-eks-cluster-kubecontrollermanagerconfig-horizontalpodautoscalercontrollerconfig
HorizontalPodAutoscalerControllerConfig *Cluster_HorizontalPodAutoscalerControllerConfig `json:"HorizontalPodAutoscalerControllerConfig,omitempty"`

// PodGcControllerConfig AWS CloudFormation Property
// Required: false
// See: https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-eks-cluster-kubecontrollermanagerconfig.html#cfn-eks-cluster-kubecontrollermanagerconfig-podgccontrollerconfig
PodGcControllerConfig *Cluster_PodGcControllerConfig `json:"PodGcControllerConfig,omitempty"`

// AWSCloudFormationDeletionPolicy represents a CloudFormation DeletionPolicy
AWSCloudFormationDeletionPolicy policies.DeletionPolicy `json:"-"`

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package eks

import (
"github.com/weaveworks/eksctl/pkg/goformation/cloudformation/policies"
"github.com/weaveworks/eksctl/pkg/goformation/cloudformation/types"
)

// Cluster_PodGcControllerConfig AWS CloudFormation Resource (AWS::EKS::Cluster.PodGcControllerConfig)
// See: https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-eks-cluster-podgccontrollerconfig.html
type Cluster_PodGcControllerConfig struct {

// TerminatedPodGcThreshold AWS CloudFormation Property
// Required: false
// See: https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-eks-cluster-podgccontrollerconfig.html#cfn-eks-cluster-podgccontrollerconfig-terminatedpodgcthreshold
TerminatedPodGcThreshold *types.Value `json:"TerminatedPodGcThreshold,omitempty"`

// AWSCloudFormationDeletionPolicy represents a CloudFormation DeletionPolicy
AWSCloudFormationDeletionPolicy policies.DeletionPolicy `json:"-"`

// AWSCloudFormationUpdateReplacePolicy represents a CloudFormation UpdateReplacePolicy
AWSCloudFormationUpdateReplacePolicy policies.UpdateReplacePolicy `json:"-"`

// AWSCloudFormationDependsOn stores the logical ID of the resources to be created before this resource
AWSCloudFormationDependsOn []string `json:"-"`

// AWSCloudFormationMetadata stores structured data associated with this resource
AWSCloudFormationMetadata map[string]interface{} `json:"-"`

// AWSCloudFormationCondition stores the logical ID of the condition that must be satisfied for this resource to be created
AWSCloudFormationCondition string `json:"-"`
}

// AWSCloudFormationType returns the AWS CloudFormation resource type
func (r *Cluster_PodGcControllerConfig) AWSCloudFormationType() string {
return "AWS::EKS::Cluster.PodGcControllerConfig"
}
Loading
Loading