Skip to content

Commit cee84d4

Browse files
Add support for ControlPlaneScalingConfig (#8590)
1 parent 1035793 commit cee84d4

File tree

15 files changed

+227
-12
lines changed

15 files changed

+227
-12
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# An example ClusterConfig with control plane scaling config
2+
apiVersion: eksctl.io/v1alpha5
3+
kind: ClusterConfig
4+
5+
metadata:
6+
name: control-plane-scaling-config-cluster
7+
region: us-west-2
8+
9+
controlPlaneScalingConfig:
10+
tier: tier-xl

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ go 1.25.1
77
require (
88
github.com/Masterminds/semver/v3 v3.4.0
99
github.com/aws/amazon-ec2-instance-selector/v3 v3.1.2
10-
github.com/aws/aws-sdk-go-v2 v1.39.6
10+
github.com/aws/aws-sdk-go-v2 v1.40.0
1111
github.com/aws/aws-sdk-go-v2/config v1.31.12
1212
github.com/aws/aws-sdk-go-v2/credentials v1.18.21
1313
github.com/aws/aws-sdk-go-v2/service/autoscaling v1.60.4
@@ -16,7 +16,7 @@ require (
1616
github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.58.8
1717
github.com/aws/aws-sdk-go-v2/service/cognitoidentityprovider v1.57.7
1818
github.com/aws/aws-sdk-go-v2/service/ec2 v1.267.0
19-
github.com/aws/aws-sdk-go-v2/service/eks v1.74.9
19+
github.com/aws/aws-sdk-go-v2/service/eks v1.75.0
2020
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.33.12
2121
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.51.6
2222
github.com/aws/aws-sdk-go-v2/service/iam v1.50.1
@@ -135,8 +135,8 @@ require (
135135
github.com/atotto/clipboard v0.1.4 // indirect
136136
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.3 // indirect
137137
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.13 // indirect
138-
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.13 // indirect
139-
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.13 // indirect
138+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.14 // indirect
139+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.14 // indirect
140140
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 // indirect
141141
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.36 // indirect
142142
github.com/aws/aws-sdk-go-v2/service/eventbridge v1.39.3 // indirect

go.sum

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z
108108
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
109109
github.com/aws/amazon-ec2-instance-selector/v3 v3.1.2 h1:F8GBspJo+RmR4rYyw75XywEEQHQxBbF7QYKaMMnYREc=
110110
github.com/aws/amazon-ec2-instance-selector/v3 v3.1.2/go.mod h1:wdlMRtz9G4IO6H1yZPsqfGBxR8E6B/bdxHlGkls4kGQ=
111-
github.com/aws/aws-sdk-go-v2 v1.39.6 h1:2JrPCVgWJm7bm83BDwY5z8ietmeJUbh3O2ACnn+Xsqk=
112-
github.com/aws/aws-sdk-go-v2 v1.39.6/go.mod h1:c9pm7VwuW0UPxAEYGyTmyurVcNrbF6Rt/wixFqDhcjE=
111+
github.com/aws/aws-sdk-go-v2 v1.40.0 h1:/WMUA0kjhZExjOQN2z3oLALDREea1A7TobfuiBrKlwc=
112+
github.com/aws/aws-sdk-go-v2 v1.40.0/go.mod h1:c9pm7VwuW0UPxAEYGyTmyurVcNrbF6Rt/wixFqDhcjE=
113113
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.3 h1:DHctwEM8P8iTXFxC/QK0MRjwEpWQeM9yzidCRjldUz0=
114114
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.3/go.mod h1:xdCzcZEtnSTKVDOmUZs4l/j3pSV6rpo1WXl5ugNsL8Y=
115115
github.com/aws/aws-sdk-go-v2/config v1.31.12 h1:pYM1Qgy0dKZLHX2cXslNacbcEFMkDMl+Bcj5ROuS6p8=
@@ -118,10 +118,10 @@ github.com/aws/aws-sdk-go-v2/credentials v1.18.21 h1:56HGpsgnmD+2/KpG0ikvvR8+3v3
118118
github.com/aws/aws-sdk-go-v2/credentials v1.18.21/go.mod h1:3YELwedmQbw7cXNaII2Wywd+YY58AmLPwX4LzARgmmA=
119119
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.13 h1:T1brd5dR3/fzNFAQch/iBKeX07/ffu/cLu+q+RuzEWk=
120120
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.13/go.mod h1:Peg/GBAQ6JDt+RoBf4meB1wylmAipb7Kg2ZFakZTlwk=
121-
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.13 h1:a+8/MLcWlIxo1lF9xaGt3J/u3yOZx+CdSveSNwjhD40=
122-
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.13/go.mod h1:oGnKwIYZ4XttyU2JWxFrwvhF6YKiK/9/wmE3v3Iu9K8=
123-
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.13 h1:HBSI2kDkMdWz4ZM7FjwE7e/pWDEZ+nR95x8Ztet1ooY=
124-
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.13/go.mod h1:YE94ZoDArI7awZqJzBAZ3PDD2zSfuP7w6P2knOzIn8M=
121+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.14 h1:PZHqQACxYb8mYgms4RZbhZG0a7dPW06xOjmaH0EJC/I=
122+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.14/go.mod h1:VymhrMJUWs69D8u0/lZ7jSB6WgaG/NqHi3gX0aYf6U0=
123+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.14 h1:bOS19y6zlJwagBfHxs0ESzr1XCOU2KXJCWcq3E2vfjY=
124+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.14/go.mod h1:1ipeGBMAxZ0xcTm6y6paC2C/J6f6OO7LBODV9afuAyM=
125125
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 h1:bIqFDwgGXXN1Kpp99pDOdKMTTb5d2KyU5X/BZxjOkRo=
126126
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3/go.mod h1:H5O/EsxDWyU+LP/V8i5sm8cxoZgc2fdNR9bxlOFrQTo=
127127
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.36 h1:GMYy2EOWfzdP3wfVAGXBNKY5vK4K8vMET4sYOYltmqs=
@@ -138,8 +138,8 @@ github.com/aws/aws-sdk-go-v2/service/cognitoidentityprovider v1.57.7 h1:1LPBlVrc
138138
github.com/aws/aws-sdk-go-v2/service/cognitoidentityprovider v1.57.7/go.mod h1:l8KDrD4EZQwTuM69YK3LFZ4c9VbNHrzaQJjJsoIFqfo=
139139
github.com/aws/aws-sdk-go-v2/service/ec2 v1.267.0 h1:WDY9IcD4z/ZCQP6YkZoTX/ck7mDGly88EmQV4VKidK4=
140140
github.com/aws/aws-sdk-go-v2/service/ec2 v1.267.0/go.mod h1:NDdDLLW5PtLLXN661gKcvJvqAH5OBXsfhMlmKVu1/pY=
141-
github.com/aws/aws-sdk-go-v2/service/eks v1.74.9 h1:ugqH9Vu52QlUhpTbW75rsv0WA9k704DEwOCoxWsLy+4=
142-
github.com/aws/aws-sdk-go-v2/service/eks v1.74.9/go.mod h1:xHVz3A2oEVl3UzjCOSEz/fBeBoFrS6FJ3cc/jo0WLyM=
141+
github.com/aws/aws-sdk-go-v2/service/eks v1.75.0 h1:89rFFYB+HtoW6no7MrEK9dYydrY7ojpyjMROyHPrlSk=
142+
github.com/aws/aws-sdk-go-v2/service/eks v1.75.0/go.mod h1:lrJRZkSj6nIXH/SN3gbGQp4i4AtNyha0wT7VgYZ3KDw=
143143
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.33.12 h1:967bczaPI2Hvw/JbrhgYGs8i6zvseiR/LJ8+LSDrdLU=
144144
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.33.12/go.mod h1:ImGbJ8W4fb8KZekLSWCnuuabYN5WusCD7cnW4Nz7i14=
145145
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.51.6 h1:4LKLhbDyzhqWXDxWD86bNvVYCSUVbY3PipJ3uF7CdJk=
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
//go:build integration
2+
3+
//revive:disable Not changing package name
4+
package cluster_config
5+
6+
import (
7+
"context"
8+
"testing"
9+
10+
"github.com/aws/aws-sdk-go-v2/aws"
11+
awseks "github.com/aws/aws-sdk-go-v2/service/eks"
12+
. "github.com/onsi/ginkgo/v2"
13+
. "github.com/onsi/gomega"
14+
15+
. "github.com/weaveworks/eksctl/integration/runner"
16+
"github.com/weaveworks/eksctl/integration/tests"
17+
clusterutils "github.com/weaveworks/eksctl/integration/utilities/cluster"
18+
api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5"
19+
"github.com/weaveworks/eksctl/pkg/awsapi"
20+
"github.com/weaveworks/eksctl/pkg/eks"
21+
"github.com/weaveworks/eksctl/pkg/testutils"
22+
)
23+
24+
var params *tests.Params
25+
26+
func init() {
27+
// Call testing.Init() prior to tests.NewParams(), as otherwise -test.* will not be recognised. See also: https://golang.org/doc/go1.13#testing
28+
testing.Init()
29+
params = tests.NewParams("cluster-config")
30+
}
31+
32+
func TestClusterConfig(t *testing.T) {
33+
testutils.RegisterAndRun(t)
34+
}
35+
36+
const (
37+
expectedControlPlaneTier = "tier-xl"
38+
expectedSupportType = api.SupportTypeStandard
39+
)
40+
41+
var eksAPI awsapi.EKS
42+
43+
var _ = BeforeSuite(func() {
44+
if params.SkipCreate {
45+
return
46+
}
47+
clusterConfig := api.NewClusterConfig()
48+
clusterConfig.Metadata.Name = params.ClusterName
49+
clusterConfig.Metadata.Region = params.Region
50+
clusterConfig.Metadata.Version = params.Version
51+
clusterConfig.ManagedNodeGroups = []*api.ManagedNodeGroup{}
52+
clusterConfig.UpgradePolicy = &api.UpgradePolicy{
53+
SupportType: expectedSupportType,
54+
}
55+
clusterConfig.ControlPlaneScalingConfig = &api.ControlPlaneScalingConfig{
56+
Tier: aws.String(expectedControlPlaneTier),
57+
}
58+
cmd := params.EksctlCreateCmd.WithArgs(
59+
"cluster",
60+
"--config-file", "-",
61+
"--verbose", "4",
62+
).
63+
WithoutArg("--region", params.Region).
64+
WithStdin(clusterutils.Reader(clusterConfig))
65+
66+
Expect(cmd).To(RunSuccessfully())
67+
68+
clusterProvider, err := eks.New(context.Background(), &api.ProviderConfig{Region: params.Region}, clusterConfig)
69+
Expect(err).NotTo(HaveOccurred())
70+
eksAPI = clusterProvider.AWSProvider.EKS()
71+
})
72+
73+
var _ = Describe("(Integration) [Cluster Config test]", func() {
74+
75+
Context("Cluster with config options", func() {
76+
77+
It("upgradePolicy should be set", func() {
78+
cluster, err := eksAPI.DescribeCluster(context.Background(), &awseks.DescribeClusterInput{
79+
Name: aws.String(params.ClusterName),
80+
})
81+
ExpectWithOffset(1, err).NotTo(HaveOccurred())
82+
Expect(string(cluster.Cluster.UpgradePolicy.SupportType)).To(Equal(expectedSupportType))
83+
})
84+
85+
It("control plane policy should be set", func() {
86+
cluster, err := eksAPI.DescribeCluster(context.Background(), &awseks.DescribeClusterInput{
87+
Name: aws.String(params.ClusterName),
88+
})
89+
ExpectWithOffset(1, err).NotTo(HaveOccurred())
90+
Expect(string(cluster.Cluster.ControlPlaneScalingConfig.Tier)).To(Equal(expectedControlPlaneTier))
91+
})
92+
})
93+
94+
})
95+
96+
var _ = AfterSuite(func() {
97+
if params.SkipDelete {
98+
return
99+
}
100+
cmd := params.EksctlDeleteCmd.WithArgs(
101+
"cluster", params.ClusterName,
102+
"--disable-nodegroup-eviction",
103+
"--verbose", "2",
104+
)
105+
Expect(cmd).To(RunSuccessfully())
106+
})

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,11 @@
467467
"description": "See [CloudWatch support](/usage/cloudwatch-cluster-logging/)",
468468
"x-intellij-html-description": "See <a href=\"/usage/cloudwatch-cluster-logging/\">CloudWatch support</a>"
469469
},
470+
"controlPlaneScalingConfig": {
471+
"$ref": "#/definitions/ControlPlaneScalingConfig",
472+
"description": "specifies control plane scaling configuration.",
473+
"x-intellij-html-description": "specifies control plane scaling configuration."
474+
},
470475
"fargateProfiles": {
471476
"items": {
472477
"$ref": "#/definitions/FargateProfile"
@@ -590,6 +595,7 @@
590595
"gitops",
591596
"karpenter",
592597
"outpost",
598+
"controlPlaneScalingConfig",
593599
"zonalShiftConfig"
594600
],
595601
"additionalProperties": false,
@@ -1029,6 +1035,19 @@
10291035
"description": "holds global subnet and all child subnets",
10301036
"x-intellij-html-description": "holds global subnet and all child subnets"
10311037
},
1038+
"ControlPlaneScalingConfig": {
1039+
"properties": {
1040+
"tier": {
1041+
"type": "string"
1042+
}
1043+
},
1044+
"preferredOrder": [
1045+
"tier"
1046+
],
1047+
"additionalProperties": false,
1048+
"description": "holds control plane scaling configuration.",
1049+
"x-intellij-html-description": "holds control plane scaling configuration."
1050+
},
10321051
"FargateProfile": {
10331052
"required": [
10341053
"name"

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,9 @@ type ClusterConfig struct {
10461046
// +optional
10471047
Outpost *Outpost `json:"outpost,omitempty"`
10481048

1049+
// ControlPlaneScalingConfig specifies control plane scaling configuration.
1050+
ControlPlaneScalingConfig *ControlPlaneScalingConfig `json:"controlPlaneScalingConfig,omitempty"`
1051+
10491052
// ZonalShiftConfig specifies the zonal shift configuration.
10501053
ZonalShiftConfig *ZonalShiftConfig `json:"zonalShiftConfig,omitempty"`
10511054
}
@@ -1075,6 +1078,11 @@ func (o *Outpost) HasPlacementGroup() bool {
10751078
return o.ControlPlanePlacement != nil
10761079
}
10771080

1081+
// ControlPlaneScalingConfig holds control plane scaling configuration.
1082+
type ControlPlaneScalingConfig struct {
1083+
Tier *string `json:"tier,omitempty"`
1084+
}
1085+
10781086
// ZonalShiftConfig holds the zonal shift configuration.
10791087
type ZonalShiftConfig struct {
10801088
// Enabled enables or disables zonal shift.

pkg/cfn/builder/cluster.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,11 @@ func (c *ClusterResourceSet) addResourcesForControlPlane(subnetDetails *SubnetDe
445445
Enabled: gfnt.NewBoolean(true),
446446
}
447447
}
448+
if c.spec.ControlPlaneScalingConfig != nil && c.spec.ControlPlaneScalingConfig.Tier != nil {
449+
cluster.ControlPlaneScalingConfig = &gfneks.Cluster_ControlPlaneScalingConfig{
450+
Tier: gfnt.NewString(*c.spec.ControlPlaneScalingConfig.Tier),
451+
}
452+
}
448453

449454
if c.spec.HasRemoteNetworkingConfigured() {
450455
cluster.RemoteNetworkConfig = &gfneks.Cluster_RemoteNetworkConfig{}

pkg/cfn/builder/cluster_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"errors"
88
"reflect"
99

10+
"github.com/aws/aws-sdk-go-v2/aws"
1011
"github.com/aws/aws-sdk-go-v2/service/cloudformation/types"
1112
"github.com/aws/aws-sdk-go-v2/service/ec2"
1213
ekstypes "github.com/aws/aws-sdk-go-v2/service/eks/types"
@@ -80,6 +81,7 @@ var _ = Describe("Cluster Template Builder", func() {
8081
Expect(controlPlane.RoleArn).To(ContainElement([]interface{}{"ServiceRole", "Arn"}))
8182
Expect(controlPlane.EncryptionConfig).To(BeNil())
8283
Expect(controlPlane.UpgradePolicy).To(BeNil())
84+
Expect(controlPlane.ControlPlaneScalingConfig).To(BeNil())
8385
Expect(controlPlane.KubernetesNetworkConfig.ServiceIPv4CIDR).To(Equal("131.10.55.70/18"))
8486
Expect(controlPlane.KubernetesNetworkConfig.IPFamily).To(Equal("ipv4"))
8587
Expect(controlPlane.AccessConfig.BootstrapClusterCreatorAdminPermissions).To(BeTrue())
@@ -98,6 +100,19 @@ var _ = Describe("Cluster Template Builder", func() {
98100
})
99101
})
100102

103+
Context("when control plane tier is set with SupportType", func() {
104+
BeforeEach(func() {
105+
cfg.ControlPlaneScalingConfig = &api.ControlPlaneScalingConfig{
106+
Tier: aws.String("tier-xl"),
107+
}
108+
})
109+
110+
It("should include UpgradePolicy with SupportType in control plane resources", func() {
111+
Expect(clusterTemplate.Resources["ControlPlane"].Properties.ControlPlaneScalingConfig).NotTo(BeNil())
112+
Expect(clusterTemplate.Resources["ControlPlane"].Properties.ControlPlaneScalingConfig.Tier).To(Equal("tier-xl"))
113+
})
114+
})
115+
101116
It("should add vpc resources", func() {
102117
Expect(clusterTemplate.Resources).To(HaveKey(vpcResourceKey))
103118
Expect(clusterTemplate.Resources).To(HaveKey(igwKey))

pkg/cfn/builder/fakes/fake_cfn_template.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ type Properties struct {
5959
SupportType string
6060
}
6161

62+
ControlPlaneScalingConfig *struct {
63+
Tier string
64+
}
65+
6266
LoadBalancerNames []string
6367
MetricsCollection []map[string]interface{}
6468
TargetGroupARNs []string

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ type Cluster struct {
5050
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-cluster.html#cfn-eks-cluster-name
5151
Name *types.Value `json:"Name,omitempty"`
5252

53+
// ControlPlaneScalingConfig AWS CloudFormation Property
54+
// Required: false
55+
// See: https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-eks-cluster-controlplanescalingconfig.html
56+
ControlPlaneScalingConfig *Cluster_ControlPlaneScalingConfig `json:"ControlPlaneScalingConfig,omitempty"`
57+
5358
// OutpostConfig AWS CloudFormation Property
5459
// Required: false
5560
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-cluster.html#cfn-eks-cluster-outpostconfig

0 commit comments

Comments
 (0)