Skip to content

Commit b2f4d39

Browse files
Add EKS clusterclass e2e suite
Signed-off-by: Alexandr Demicev <[email protected]>
1 parent ce8e91a commit b2f4d39

File tree

4 files changed

+218
-0
lines changed

4 files changed

+218
-0
lines changed

test/e2e/data/e2e_eks_conf.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ providers:
114114
targetName: "cluster-template-eks-ipv6-cluster.yaml"
115115
- sourcePath: "./eks/cluster-template-eks-control-plane-only-legacy.yaml"
116116
targetName: "cluster-template-eks-control-plane-only-legacy.yaml"
117+
- sourcePath: "./eks/cluster-template-eks-clusterclass.yaml"
118+
targetName: "cluster-template-eks-clusterclass.yaml"
117119

118120
variables:
119121
KUBERNETES_VERSION: "v1.31.0"
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
apiVersion: cluster.x-k8s.io/v1beta1
2+
kind: ClusterClass
3+
metadata:
4+
name: capa-e2e-eks
5+
spec:
6+
controlPlane:
7+
ref:
8+
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
9+
kind: AWSManagedControlPlaneTemplate
10+
name: "${CLUSTER_NAME}-control-plane"
11+
infrastructure:
12+
ref:
13+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
14+
kind: AWSManagedClusterTemplate
15+
name: "${CLUSTER_NAME}"
16+
workers:
17+
machineDeployments:
18+
- class: default-worker
19+
template:
20+
bootstrap:
21+
ref:
22+
name: "${CLUSTER_NAME}-md-0"
23+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta2
24+
kind: EKSConfigTemplate
25+
infrastructure:
26+
ref:
27+
name: "${CLUSTER_NAME}-md-0"
28+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
29+
kind: AWSMachineTemplate
30+
---
31+
kind: AWSManagedClusterTemplate
32+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
33+
metadata:
34+
name: "${CLUSTER_NAME}"
35+
spec:
36+
template:
37+
spec: {}
38+
---
39+
kind: AWSManagedControlPlaneTemplate
40+
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
41+
metadata:
42+
name: "${CLUSTER_NAME}-control-plane"
43+
spec:
44+
template:
45+
spec:
46+
region: "${AWS_REGION}"
47+
sshKeyName: "${AWS_SSH_KEY_NAME}"
48+
version: "${KUBERNETES_VERSION}"
49+
---
50+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
51+
kind: AWSMachineTemplate
52+
metadata:
53+
name: "${CLUSTER_NAME}-md-0"
54+
spec:
55+
template:
56+
spec:
57+
instanceType: "${AWS_NODE_MACHINE_TYPE}"
58+
iamInstanceProfile: "nodes.cluster-api-provider-aws.sigs.k8s.io"
59+
sshKeyName: "${AWS_SSH_KEY_NAME}"
60+
---
61+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta2
62+
kind: EKSConfigTemplate
63+
metadata:
64+
name: "${CLUSTER_NAME}-md-0"
65+
spec:
66+
template: {}
67+
---
68+
apiVersion: cluster.x-k8s.io/v1beta1
69+
kind: Cluster
70+
metadata:
71+
name: "${CLUSTER_NAME}"
72+
spec:
73+
clusterNetwork:
74+
pods:
75+
cidrBlocks:
76+
- 192.168.0.0/16
77+
topology:
78+
class: capa-e2e-eks
79+
version: "${KUBERNETES_VERSION}"
80+
workers:
81+
machineDeployments:
82+
- class: default-worker
83+
name: md-0
84+
replicas: ${WORKER_MACHINE_COUNT}
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
//go:build e2e
2+
// +build e2e
3+
4+
/*
5+
Copyright 2025 The Kubernetes Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
*/
19+
20+
package managed
21+
22+
import (
23+
"context"
24+
"fmt"
25+
26+
"github.com/onsi/ginkgo/v2"
27+
. "github.com/onsi/gomega"
28+
corev1 "k8s.io/api/core/v1"
29+
30+
ekscontrolplanev1 "sigs.k8s.io/cluster-api-provider-aws/v2/controlplane/eks/api/v1beta2"
31+
"sigs.k8s.io/cluster-api-provider-aws/v2/test/e2e/shared"
32+
"sigs.k8s.io/cluster-api/test/framework"
33+
"sigs.k8s.io/cluster-api/util"
34+
)
35+
36+
// Clusterclass EKS e2e test.
37+
var _ = ginkgo.Describe("[managed] [general] EKS clusterclass tests", func() {
38+
var (
39+
namespace *corev1.Namespace
40+
ctx context.Context
41+
specName = "cluster"
42+
clusterName string
43+
cniAddonName = "vpc-cni"
44+
)
45+
46+
shared.ConditionalIt(runGeneralTests, "should create a cluster and add nodes", func() {
47+
ginkgo.By("should have a valid test configuration")
48+
Expect(e2eCtx.Environment.BootstrapClusterProxy).ToNot(BeNil(), "Invalid argument. BootstrapClusterProxy can't be nil")
49+
Expect(e2eCtx.E2EConfig).ToNot(BeNil(), "Invalid argument. e2eConfig can't be nil when calling %s spec", specName)
50+
Expect(e2eCtx.E2EConfig.Variables).To(HaveKey(shared.KubernetesVersion))
51+
Expect(e2eCtx.E2EConfig.Variables).To(HaveKey(shared.CNIAddonVersion))
52+
53+
ctx = context.TODO()
54+
namespace = shared.SetupSpecNamespace(ctx, specName, e2eCtx)
55+
clusterName = fmt.Sprintf("%s-%s", specName, util.RandomString(6))
56+
eksClusterName := getEKSClusterName(namespace.Name, clusterName)
57+
58+
ginkgo.By("default iam role should exist")
59+
VerifyRoleExistsAndOwned(ekscontrolplanev1.DefaultEKSControlPlaneRole, eksClusterName, false, e2eCtx.BootstrapUserAWSSession)
60+
61+
ginkgo.By("should create an EKS control plane")
62+
ManagedClusterSpec(ctx, func() ManagedClusterSpecInput {
63+
return ManagedClusterSpecInput{
64+
E2EConfig: e2eCtx.E2EConfig,
65+
ConfigClusterFn: defaultConfigCluster,
66+
BootstrapClusterProxy: e2eCtx.Environment.BootstrapClusterProxy,
67+
AWSSession: e2eCtx.BootstrapUserAWSSession,
68+
Namespace: namespace,
69+
ClusterName: clusterName,
70+
Flavour: EKSClusterClassFlavor,
71+
ControlPlaneMachineCount: 1, // NOTE: this cannot be zero as clusterctl returns an error
72+
WorkerMachineCount: 0,
73+
}
74+
})
75+
76+
ginkgo.By("should set environment variables on the aws-node daemonset")
77+
CheckAwsNodeEnvVarsSet(ctx, func() UpdateAwsNodeVersionSpecInput {
78+
return UpdateAwsNodeVersionSpecInput{
79+
E2EConfig: e2eCtx.E2EConfig,
80+
BootstrapClusterProxy: e2eCtx.Environment.BootstrapClusterProxy,
81+
AWSSession: e2eCtx.BootstrapUserAWSSession,
82+
Namespace: namespace,
83+
ClusterName: clusterName,
84+
}
85+
})
86+
87+
ginkgo.By("should have the VPC CNI installed")
88+
CheckAddonExistsSpec(ctx, func() CheckAddonExistsSpecInput {
89+
return CheckAddonExistsSpecInput{
90+
E2EConfig: e2eCtx.E2EConfig,
91+
BootstrapClusterProxy: e2eCtx.Environment.BootstrapClusterProxy,
92+
AWSSession: e2eCtx.BootstrapUserAWSSession,
93+
Namespace: namespace,
94+
ClusterName: clusterName,
95+
AddonName: cniAddonName,
96+
AddonVersion: e2eCtx.E2EConfig.GetVariable(shared.CNIAddonVersion),
97+
}
98+
})
99+
100+
ginkgo.By("should create a MachineDeployment")
101+
MachineDeploymentSpec(ctx, func() MachineDeploymentSpecInput {
102+
return MachineDeploymentSpecInput{
103+
E2EConfig: e2eCtx.E2EConfig,
104+
ConfigClusterFn: defaultConfigCluster,
105+
BootstrapClusterProxy: e2eCtx.Environment.BootstrapClusterProxy,
106+
AWSSession: e2eCtx.BootstrapUserAWSSession,
107+
Namespace: namespace,
108+
ClusterName: clusterName,
109+
Replicas: 1,
110+
Cleanup: true,
111+
}
112+
})
113+
114+
ginkgo.By(fmt.Sprintf("getting cluster with name %s", clusterName))
115+
cluster := framework.GetClusterByName(ctx, framework.GetClusterByNameInput{
116+
Getter: e2eCtx.Environment.BootstrapClusterProxy.GetClient(),
117+
Namespace: namespace.Name,
118+
Name: clusterName,
119+
})
120+
Expect(cluster).NotTo(BeNil(), "couldn't find CAPI cluster")
121+
122+
framework.DeleteCluster(ctx, framework.DeleteClusterInput{
123+
Deleter: e2eCtx.Environment.BootstrapClusterProxy.GetClient(),
124+
Cluster: cluster,
125+
})
126+
framework.WaitForClusterDeleted(ctx, framework.WaitForClusterDeletedInput{
127+
Client: e2eCtx.Environment.BootstrapClusterProxy.GetClient(),
128+
Cluster: cluster,
129+
}, e2eCtx.E2EConfig.GetIntervals("", "wait-delete-cluster")...)
130+
})
131+
})

test/e2e/suites/managed/helpers.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const (
5050
EKSMachinePoolOnlyFlavor = "eks-machinepool-only"
5151
EKSIPv6ClusterFlavor = "eks-ipv6-cluster"
5252
EKSControlPlaneOnlyLegacyFlavor = "eks-control-plane-only-legacy"
53+
EKSClusterClassFlavor = "eks-clusterclass"
5354
)
5455

5556
const (

0 commit comments

Comments
 (0)