Skip to content

Commit 151e553

Browse files
Add feature flags for K8s 1.33 (#9706)
1 parent 2dd7955 commit 151e553

File tree

8 files changed

+67
-3
lines changed

8 files changed

+67
-3
lines changed

pkg/api/v1alpha1/cluster_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,7 @@ const (
844844
Kube130 KubernetesVersion = "1.30"
845845
Kube131 KubernetesVersion = "1.31"
846846
Kube132 KubernetesVersion = "1.32"
847+
Kube133 KubernetesVersion = "1.33"
847848
)
848849

849850
// KubeVersionToSemver converts kube version to semver for comparisons.

pkg/features/features.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const (
99
VSphereInPlaceEnvVar = "VSPHERE_IN_PLACE_UPGRADE"
1010
APIServerExtraArgsEnabledEnvVar = "API_SERVER_EXTRA_ARGS_ENABLED"
1111
VSphereFailureDomainEnabledEnvVar = "VSPHERE_FAILURE_DOMAIN_ENABLED"
12+
K8s133SupportEnvVar = "K8S_1_33_SUPPORT"
1213
)
1314

1415
func FeedGates(featureGates []string) {
@@ -73,3 +74,11 @@ func VsphereFailureDomainEnabled() Feature {
7374
IsActive: globalFeatures.isActiveForEnvVar(VSphereFailureDomainEnabledEnvVar),
7475
}
7576
}
77+
78+
// K8s133Support is the feature flag for Kubernetes 1.33 support.
79+
func K8s133Support() Feature {
80+
return Feature{
81+
Name: "Kubernetes version 1.33 support",
82+
IsActive: globalFeatures.isActiveForEnvVar(K8s133SupportEnvVar),
83+
}
84+
}

pkg/features/features_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,11 @@ func TestWithVsphereFailureDomainsFeatureFlag(t *testing.T) {
9393
g.Expect(os.Setenv(VSphereFailureDomainEnabledEnvVar, "true")).To(Succeed())
9494
g.Expect(IsActive(VsphereFailureDomainEnabled())).To(BeTrue())
9595
}
96+
97+
func TestWithK8s133FeatureFlag(t *testing.T) {
98+
g := NewWithT(t)
99+
setupContext(t)
100+
101+
g.Expect(os.Setenv(K8s133SupportEnvVar, "true")).To(Succeed())
102+
g.Expect(IsActive(K8s133Support())).To(BeTrue())
103+
}

pkg/validations/cluster.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/aws/eks-anywhere/pkg/cluster"
1111
"github.com/aws/eks-anywhere/pkg/config"
1212
"github.com/aws/eks-anywhere/pkg/constants"
13+
"github.com/aws/eks-anywhere/pkg/features"
1314
"github.com/aws/eks-anywhere/pkg/logger"
1415
"github.com/aws/eks-anywhere/pkg/manifests"
1516
"github.com/aws/eks-anywhere/pkg/manifests/bundles"
@@ -318,3 +319,13 @@ func ValidateExtendedKubernetesSupport(ctx context.Context, clusterSpec v1alpha1
318319
}
319320
return ValidateExtendedK8sVersionSupport(ctx, clusterSpec, b, k)
320321
}
322+
323+
// ValidateK8s133Support checks if the 1.33 feature flag is set when using k8s 1.33.
324+
func ValidateK8s133Support(clusterSpec *cluster.Spec) error {
325+
if !features.IsActive(features.K8s133Support()) {
326+
if clusterSpec.Cluster.Spec.KubernetesVersion == v1alpha1.Kube133 {
327+
return fmt.Errorf("kubernetes version %s is not enabled. Please set the env variable %v", v1alpha1.Kube133, features.K8s133SupportEnvVar)
328+
}
329+
}
330+
return nil
331+
}

pkg/validations/cluster_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
internalmocks "github.com/aws/eks-anywhere/internal/test/mocks"
1919
anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1"
2020
"github.com/aws/eks-anywhere/pkg/cluster"
21+
"github.com/aws/eks-anywhere/pkg/features"
2122
"github.com/aws/eks-anywhere/pkg/manifests"
2223
"github.com/aws/eks-anywhere/pkg/manifests/releases"
2324
"github.com/aws/eks-anywhere/pkg/providers"
@@ -1157,3 +1158,18 @@ spec:
11571158
})
11581159
}
11591160
}
1161+
1162+
func TestValidateK8s133Support(t *testing.T) {
1163+
tt := newTest(t)
1164+
tt.clusterSpec.Cluster.Spec.KubernetesVersion = anywherev1.Kube133
1165+
tt.Expect(validations.ValidateK8s133Support(tt.clusterSpec)).To(
1166+
MatchError(ContainSubstring("kubernetes version 1.33 is not enabled. Please set the env variable K8S_1_33_SUPPORT")))
1167+
}
1168+
1169+
func TestValidateK8s133SupportActive(t *testing.T) {
1170+
tt := newTest(t)
1171+
tt.clusterSpec.Cluster.Spec.KubernetesVersion = anywherev1.Kube133
1172+
features.ClearCache()
1173+
os.Setenv(features.K8s133SupportEnvVar, "true")
1174+
tt.Expect(validations.ValidateK8s133Support(tt.clusterSpec)).To(Succeed())
1175+
}

pkg/validations/createvalidations/preflightvalidations.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import (
44
"context"
55
"fmt"
66

7-
"github.com/aws/eks-anywhere/pkg/api/v1alpha1"
87
anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1"
98
"github.com/aws/eks-anywhere/pkg/config"
109
"github.com/aws/eks-anywhere/pkg/constants"
10+
"github.com/aws/eks-anywhere/pkg/features"
1111
"github.com/aws/eks-anywhere/pkg/types"
1212
"github.com/aws/eks-anywhere/pkg/validations"
1313
)
@@ -57,11 +57,19 @@ func (v *CreateValidations) PreflightValidations(ctx context.Context) []validati
5757
Err: validations.ValidateExtendedKubernetesSupport(ctx, *v.Opts.Spec.Cluster, v.Opts.ManifestReader, v.Opts.KubeClient, v.Opts.BundlesOverride),
5858
}
5959
},
60+
func() *validations.ValidationResult {
61+
return &validations.ValidationResult{
62+
Name: "validate kubernetes version 1.33 support",
63+
Remediation: fmt.Sprintf("ensure %v env variable is set", features.K8s133SupportEnvVar),
64+
Err: validations.ValidateK8s133Support(v.Opts.Spec),
65+
Silent: true,
66+
}
67+
},
6068
}
6169

6270
if len(v.Opts.Spec.VSphereMachineConfigs) != 0 {
6371
cpRef := v.Opts.Spec.Cluster.Spec.ControlPlaneConfiguration.MachineGroupRef.Name
64-
if v.Opts.Spec.VSphereMachineConfigs[cpRef].Spec.OSFamily == v1alpha1.Bottlerocket {
72+
if v.Opts.Spec.VSphereMachineConfigs[cpRef].Spec.OSFamily == anywherev1.Bottlerocket {
6573
createValidations = append(createValidations,
6674
func() *validations.ValidationResult {
6775
return &validations.ValidationResult{

pkg/validations/upgradevalidations/preflightvalidations.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
anywherev1 "github.com/aws/eks-anywhere/pkg/api/v1alpha1"
1010
"github.com/aws/eks-anywhere/pkg/config"
1111
"github.com/aws/eks-anywhere/pkg/constants"
12+
"github.com/aws/eks-anywhere/pkg/features"
1213
"github.com/aws/eks-anywhere/pkg/providers"
1314
"github.com/aws/eks-anywhere/pkg/types"
1415
"github.com/aws/eks-anywhere/pkg/validation"
@@ -129,6 +130,14 @@ func (u *UpgradeValidations) PreflightValidations(ctx context.Context) []validat
129130
Err: validations.ValidateExtendedKubernetesSupport(ctx, *u.Opts.Spec.Cluster, u.Opts.ManifestReader, u.Opts.KubeClient, u.Opts.BundlesOverride),
130131
}
131132
},
133+
func() *validations.ValidationResult {
134+
return &validations.ValidationResult{
135+
Name: "validate kubernetes version 1.33 support",
136+
Remediation: fmt.Sprintf("ensure %v env variable is set", features.K8s133SupportEnvVar),
137+
Err: validations.ValidateK8s133Support(u.Opts.Spec),
138+
Silent: true,
139+
}
140+
},
132141
}
133142

134143
if len(u.Opts.Spec.VSphereMachineConfigs) != 0 {

test/framework/cluster.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
"github.com/aws/eks-anywhere/pkg/cluster"
3737
"github.com/aws/eks-anywhere/pkg/constants"
3838
"github.com/aws/eks-anywhere/pkg/executables"
39+
"github.com/aws/eks-anywhere/pkg/features"
3940
"github.com/aws/eks-anywhere/pkg/filewriter"
4041
"github.com/aws/eks-anywhere/pkg/git"
4142
"github.com/aws/eks-anywhere/pkg/providers/cloudstack/decoder"
@@ -2277,11 +2278,12 @@ func dumpFile(description, path string, t T) {
22772278
func (e *ClusterE2ETest) setFeatureFlagForUnreleasedKubernetesVersion(version v1alpha1.KubernetesVersion) {
22782279
// Update this variable to equal the feature flagged k8s version when applicable.
22792280
// For example, if k8s 1.31 is under a feature flag, we would set this to v1alpha1.Kube131
2280-
var unreleasedK8sVersion v1alpha1.KubernetesVersion
2281+
unreleasedK8sVersion := v1alpha1.Kube133
22812282

22822283
if version == unreleasedK8sVersion {
22832284
// Set feature flag for the unreleased k8s version when applicable
22842285
e.T.Logf("Setting k8s version support feature flag...")
2286+
os.Setenv(features.K8s133SupportEnvVar, "true")
22852287
}
22862288
}
22872289

0 commit comments

Comments
 (0)