Skip to content

Commit a6c8769

Browse files
committed
feat: add support for UpgradePolicy attribute in cluster creation
Fixes #7932
1 parent 5f55c80 commit a6c8769

File tree

7 files changed

+187
-0
lines changed

7 files changed

+187
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: eksctl.io/v1alpha5
2+
kind: ClusterConfig
3+
4+
metadata:
5+
name: upgrade-policy-cluster
6+
region: us-west-2
7+
version: "1.34"
8+
# UpgradePolicy allows you to specify the support type for your cluster
9+
# Valid values are "STANDARD" and "EXTENDED (default)"
10+
# - https://docs.aws.amazon.com/eks/latest/APIReference/API_UpgradePolicyRequest.html
11+
upgradePolicy:
12+
supportType: "EXTENDED"
13+
14+
# Managed node group
15+
managedNodeGroups:
16+
- name: mng-1
17+
instanceType: m5.large
18+
desiredCapacity: 1
19+
minSize: 1
20+
maxSize: 2

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,11 @@
850850
"x-intellij-html-description": "used to tag AWS resources created by eksctl",
851851
"default": "{}"
852852
},
853+
"upgradePolicy": {
854+
"$ref": "#/definitions/UpgradePolicy",
855+
"description": "specifies the upgrade policy for the cluster",
856+
"x-intellij-html-description": "specifies the upgrade policy for the cluster"
857+
},
853858
"version": {
854859
"type": "string",
855860
"description": "use `./eksctl utils describe-cluster-versions` to get the list of supported versions",
@@ -861,6 +866,7 @@
861866
"region",
862867
"version",
863868
"forceUpdateVersion",
869+
"upgradePolicy",
864870
"tags",
865871
"annotations"
866872
],
@@ -2719,6 +2725,26 @@
27192725
"description": "defines the configuration for KMS encryption provider",
27202726
"x-intellij-html-description": "defines the configuration for KMS encryption provider"
27212727
},
2728+
"UpgradePolicy": {
2729+
"properties": {
2730+
"supportType": {
2731+
"type": "string",
2732+
"description": "specifies the support type for the cluster. Valid variants are: `\"STANDARD\"` standard support for the cluster, `\"EXTENDED\"` extended support for the cluster (default) defines the default support type.",
2733+
"x-intellij-html-description": "specifies the support type for the cluster. Valid variants are: <code>&quot;STANDARD&quot;</code> standard support for the cluster, <code>&quot;EXTENDED&quot;</code> extended support for the cluster (default) defines the default support type.",
2734+
"default": "EXTENDED",
2735+
"enum": [
2736+
"STANDARD",
2737+
"EXTENDED"
2738+
]
2739+
}
2740+
},
2741+
"preferredOrder": [
2742+
"supportType"
2743+
],
2744+
"additionalProperties": false,
2745+
"description": "holds the upgrade policy configuration for the cluster",
2746+
"x-intellij-html-description": "holds the upgrade policy configuration for the cluster"
2747+
},
27222748
"VPCGateway": {
27232749
"type": "string",
27242750
"description": "VPCGatewayID the ID of the gateway that facilitates external connectivity from customer's VPC to their remote network(s). Valid options are Transit Gateway and Virtual Private Gateway.",

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,16 @@ const (
451451
NoneCapacityReservation = "none"
452452
)
453453

454+
// Values for `SupportType`
455+
const (
456+
// SupportTypeStandard standard support for the cluster
457+
SupportTypeStandard = "STANDARD"
458+
// SupportTypeExtended extended support for the cluster (default)
459+
SupportTypeExtended = "EXTENDED"
460+
// DefaultSupportType defines the default support type
461+
DefaultSupportType = SupportTypeExtended
462+
)
463+
454464
var (
455465
// DefaultIPFamily defines the default IP family to use when creating a new VPC and cluster.
456466
DefaultIPFamily = IPV4Family
@@ -663,6 +673,9 @@ type ClusterMeta struct {
663673
// When updating cluster version, provide the force flag to override upgrade-blocking insights
664674
// +optional
665675
ForceUpdateVersion *bool `json:"forceUpdateVersion,omitempty"`
676+
// UpgradePolicy specifies the upgrade policy for the cluster
677+
// +optional
678+
UpgradePolicy *UpgradePolicy `json:"upgradePolicy,omitempty"`
666679
// Tags are used to tag AWS resources created by eksctl
667680
// +optional
668681
Tags map[string]string `json:"tags,omitempty"`
@@ -674,6 +687,14 @@ type ClusterMeta struct {
674687
AccountID string `json:"-"`
675688
}
676689

690+
// UpgradePolicy holds the upgrade policy configuration for the cluster
691+
type UpgradePolicy struct {
692+
// SupportType specifies the support type for the cluster.
693+
// Valid variants are `SupportType` constants
694+
// +optional
695+
SupportType string `json:"supportType,omitempty"`
696+
}
697+
677698
// KubernetesNetworkConfig contains cluster networking options
678699
type KubernetesNetworkConfig struct {
679700
// Valid variants are `IPFamily` constants

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,31 @@ func (c *ClusterConfig) validateRemoteNetworkingConfig() error {
143143
return nil
144144
}
145145

146+
// validateSupportType performs secure validation of the support type string
147+
func validateSupportType(supportType string) error {
148+
// Security: Validate characters to prevent injection attacks
149+
for _, r := range supportType {
150+
if r < 32 || r == 127 { // Control characters
151+
return fmt.Errorf("upgradePolicy.supportType contains invalid control characters")
152+
}
153+
}
154+
// Validate against allowed values
155+
if supportType != SupportTypeStandard && supportType != SupportTypeExtended {
156+
return fmt.Errorf("upgradePolicy.supportType must be either %q or %q", SupportTypeStandard, SupportTypeExtended)
157+
}
158+
return nil
159+
}
160+
146161
// ValidateClusterConfig checks compatible fields of a given ClusterConfig
147162
func ValidateClusterConfig(cfg *ClusterConfig) error {
163+
if cfg.Metadata.UpgradePolicy != nil {
164+
if cfg.Metadata.UpgradePolicy.SupportType != "" {
165+
if err := validateSupportType(cfg.Metadata.UpgradePolicy.SupportType); err != nil {
166+
return err
167+
}
168+
}
169+
}
170+
148171
if IsDisabled(cfg.IAM.WithOIDC) && len(cfg.IAM.ServiceAccounts) > 0 {
149172
return fmt.Errorf("iam.withOIDC must be enabled explicitly for iam.serviceAccounts to be created")
150173
}

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

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

userdocs/mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ nav:
157157
- usage/fargate-support.md
158158
- usage/cluster-upgrade.md
159159
- usage/addon-upgrade.md
160+
- usage/upgrade-policy.md
160161
- usage/zonal-shift.md
161162
- Nodegroups:
162163
- usage/nodegroups.md
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Cluster Upgrade Policy
2+
3+
This document describes how to configure the upgrade policy for your EKS cluster using eksctl.
4+
5+
## Overview
6+
7+
The `upgradePolicy` field allows you to specify the support type for your EKS cluster. This determines the level of support AWS provides for your cluster version.
8+
9+
## Support Types
10+
11+
- **STANDARD**: The default support type that provides standard AWS support for the cluster
12+
- **EXTENDED**: Provides extended support for older Kubernetes versions beyond the standard support period
13+
14+
## Configuration
15+
16+
You can specify the upgrade policy in your cluster configuration file:
17+
18+
```yaml
19+
apiVersion: eksctl.io/v1alpha5
20+
kind: ClusterConfig
21+
22+
metadata:
23+
name: my-cluster
24+
region: us-west-2
25+
version: "1.34"
26+
upgradePolicy:
27+
supportType: "EXTENDED" # or "STANDARD"
28+
29+
managedNodeGroups:
30+
- name: mng-1
31+
instanceType: m5.large
32+
desiredCapacity: 1
33+
```
34+
35+
## Command Line Usage
36+
37+
When creating a cluster with a specific upgrade policy:
38+
39+
```bash
40+
eksctl create cluster --config-file=cluster-config.yaml
41+
```
42+
43+
## Examples
44+
45+
### Extended Support (Default)
46+
```yaml
47+
metadata:
48+
name: extended-cluster
49+
region: us-west-2
50+
upgradePolicy:
51+
supportType: "EXTENDED"
52+
```
53+
54+
### Standard Support
55+
```yaml
56+
metadata:
57+
name: standard-cluster
58+
region: us-west-2
59+
upgradePolicy:
60+
supportType: "STANDARD"
61+
```
62+
63+
### No Upgrade Policy (Uses AWS Default)
64+
```yaml
65+
metadata:
66+
name: default-cluster
67+
region: us-west-2
68+
# No upgradePolicy specified - uses AWS default behavior
69+
```
70+
71+
## Notes
72+
73+
- If no `upgradePolicy` is specified, AWS will use its default behavior
74+
- The upgrade policy can only be set during cluster creation
75+
- Extended support may incur additional costs - refer to AWS EKS pricing documentation

0 commit comments

Comments
 (0)