Skip to content

Commit 012bfb1

Browse files
Add EKS clusterclass e2e suite
Signed-off-by: Alexandr Demicev <[email protected]> Co-authored-by: Richard Case <[email protected]>
1 parent 4f917bc commit 012bfb1

File tree

6 files changed

+228
-1
lines changed

6 files changed

+228
-1
lines changed

test/e2e/data/e2e_eks_conf.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ images:
1616
- name: gcr.io/k8s-staging-cluster-api/capa-manager:e2e
1717
loadBehavior: mustLoad
1818

19-
## PLEASE KEEP THESE UP TO DATE WITH THE COMPONENTS
19+
## PLEASE KEEP THESE UP TO DATE WITH THE COMPONENTS
2020
- name: quay.io/jetstack/cert-manager-cainjector:v1.16.1
2121
loadBehavior: tryLoad
2222
- name: quay.io/jetstack/cert-manager-webhook:v1.16.1
@@ -116,6 +116,8 @@ providers:
116116
targetName: "cluster-template-eks-control-plane-only-legacy.yaml"
117117
- sourcePath: "./eks/cluster-template-eks-control-plane-bare-eks.yaml"
118118
targetName: "cluster-template-eks-control-plane-bare-eks.yaml"
119+
- sourcePath: "./infrastructure-aws/withclusterclass/kustomize_sources/eks-clusterclass/clusterclass-eks-e2e.yaml"
120+
- sourcePath: "./infrastructure-aws/withclusterclass/generated/cluster-template-eks-clusterclass.yaml"
119121

120122
variables:
121123
KUBERNETES_VERSION: "v1.31.0"
@@ -124,6 +126,7 @@ variables:
124126
UPGRADE_FROM_VERSION: "v1.30.8"
125127
EXP_MACHINE_POOL: "true"
126128
EXP_CLUSTER_RESOURCE_SET: "true"
129+
CLUSTER_TOPOLOGY: "true"
127130
EVENT_BRIDGE_INSTANCE_STATE: "true"
128131
AWS_NODE_MACHINE_TYPE: t3.large
129132
AWS_MACHINE_TYPE_VCPU_USAGE: 2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: cluster.x-k8s.io/v1beta1
2+
kind: Cluster
3+
metadata:
4+
name: "${CLUSTER_NAME}"
5+
spec:
6+
clusterNetwork:
7+
pods:
8+
cidrBlocks:
9+
- 192.168.0.0/16
10+
topology:
11+
class: eks-e2e
12+
version: "${KUBERNETES_VERSION}"
13+
workers:
14+
machineDeployments:
15+
- class: default-worker
16+
name: md-0
17+
replicas: ${WORKER_MACHINE_COUNT}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
apiVersion: cluster.x-k8s.io/v1beta1
2+
kind: ClusterClass
3+
metadata:
4+
name: eks-e2e
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: {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
resources:
2+
- cluster-template.yaml
3+
generatorOptions:
4+
disableNameSuffixHash: true
5+
labels:
6+
type: generated
7+
annotations:
8+
note: generated
9+
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)