Skip to content

Commit dd6a97f

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

File tree

7 files changed

+154
-0
lines changed

7 files changed

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

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,11 @@
550550
"secretsEncryption": {
551551
"$ref": "#/definitions/SecretsEncryption"
552552
},
553+
"upgradePolicy": {
554+
"$ref": "#/definitions/UpgradePolicy",
555+
"description": "specifies the upgrade policy for the cluster",
556+
"x-intellij-html-description": "specifies the upgrade policy for the cluster"
557+
},
553558
"vpc": {
554559
"$ref": "#/definitions/ClusterVPC"
555560
},
@@ -563,6 +568,7 @@
563568
"kind",
564569
"apiVersion",
565570
"metadata",
571+
"upgradePolicy",
566572
"kubernetesNetworkConfig",
567573
"autoModeConfig",
568574
"remoteNetworkConfig",
@@ -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: 22 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
@@ -674,6 +684,14 @@ type ClusterMeta struct {
674684
AccountID string `json:"-"`
675685
}
676686

687+
// UpgradePolicy holds the upgrade policy configuration for the cluster
688+
type UpgradePolicy struct {
689+
// SupportType specifies the support type for the cluster.
690+
// Valid variants are `SupportType` constants
691+
// +optional
692+
SupportType string `json:"supportType,omitempty"`
693+
}
694+
677695
// KubernetesNetworkConfig contains cluster networking options
678696
type KubernetesNetworkConfig struct {
679697
// Valid variants are `IPFamily` constants
@@ -935,6 +953,10 @@ type ClusterConfig struct {
935953
// +required
936954
Metadata *ClusterMeta `json:"metadata"`
937955

956+
// UpgradePolicy specifies the upgrade policy for the cluster
957+
// +optional
958+
UpgradePolicy *UpgradePolicy `json:"upgradePolicy,omitempty"`
959+
938960
// +optional
939961
KubernetesNetworkConfig *KubernetesNetworkConfig `json:"kubernetesNetworkConfig,omitempty"`
940962

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.UpgradePolicy != nil {
164+
if cfg.UpgradePolicy.SupportType != "" {
165+
if err := validateSupportType(cfg.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: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
26+
upgradePolicy:
27+
supportType: "EXTENDED" # or "STANDARD"
28+
```
29+
30+
## Command Line Usage
31+
32+
When creating a cluster with a specific upgrade policy:
33+
34+
```bash
35+
eksctl create cluster --config-file=cluster-config.yaml
36+
```
37+
38+
## Notes
39+
40+
- If no `upgradePolicy` is specified, AWS will use its default behavior
41+
- The upgrade policy can only be set during cluster creation
42+
- Extended support may incur additional costs - refer to AWS EKS pricing documentation

0 commit comments

Comments
 (0)