Skip to content

Commit d657f69

Browse files
committed
e2e: adds flavor and e2e test for nodeadm clusterclass
1 parent fd62f07 commit d657f69

File tree

9 files changed

+256
-1
lines changed

9 files changed

+256
-1
lines changed

bootstrap/eks/controllers/nodeadmconfig_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func (r *NodeadmConfigReconciler) joinWorker(ctx context.Context, cluster *clust
209209
Mounts: config.Spec.Mounts,
210210
Files: files,
211211
ServiceCIDR: serviceCIDR,
212-
APIServerEndpoint: controlPlane.Spec.ControlPlaneEndpoint.Host,
212+
APIServerEndpoint: cluster.Spec.ControlPlaneEndpoint.Host,
213213
}
214214
if config.Spec.Kubelet != nil {
215215
nodeInput.KubeletFlags = config.Spec.Kubelet.Flags

bootstrap/eks/controllers/nodeadmconfig_controller_reconciler_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func TestNodeadmConfigReconciler_CreateSecret(t *testing.T) {
3939
endpoint := clusterv1.APIEndpoint{Host: "https://9.9.9.9", Port: 6443}
4040
amcp.Spec.ControlPlaneEndpoint = endpoint
4141
cluster := newCluster(amcp.Name)
42+
cluster.Spec.ControlPlaneEndpoint = endpoint
4243
newStatus := cluster.Status
4344
amcpStatus := amcp.Status
4445
g.Expect(testEnv.Client.Create(ctx, amcp)).To(Succeed())
@@ -77,6 +78,7 @@ func TestNodeadmConfigReconciler_UpdateSecret_ForMachinePool(t *testing.T) {
7778
endpoint := clusterv1.APIEndpoint{Host: "https://9.9.9.9", Port: 6443}
7879
amcp.Spec.ControlPlaneEndpoint = endpoint
7980
cluster := newCluster(amcp.Name)
81+
cluster.Spec.ControlPlaneEndpoint = endpoint
8082
newStatus := cluster.Status
8183
amcpStatus := amcp.Status
8284
g.Expect(testEnv.Client.Create(ctx, amcp)).To(Succeed())
@@ -137,6 +139,7 @@ func TestNodeadmConfigReconciler_ResolvesSecretFileReference(t *testing.T) {
137139
endpoint := clusterv1.APIEndpoint{Host: "https://9.9.9.9", Port: 6443}
138140
amcp.Spec.ControlPlaneEndpoint = endpoint
139141
cluster := newCluster(amcp.Name)
142+
cluster.Spec.ControlPlaneEndpoint = endpoint
140143
newStatus := cluster.Status
141144
amcpStatus := amcp.Status
142145
g.Expect(testEnv.Client.Create(ctx, amcp)).To(Succeed())
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
apiVersion: cluster.x-k8s.io/v1beta1
2+
kind: ClusterClass
3+
metadata:
4+
name: ${CLUSTER_CLASS_NAME}
5+
spec:
6+
controlPlane:
7+
ref:
8+
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
9+
kind: AWSManagedControlPlaneTemplate
10+
name: "${CLUSTER_CLASS_NAME}-control-plane"
11+
infrastructure:
12+
ref:
13+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
14+
kind: AWSManagedClusterTemplate
15+
name: "${CLUSTER_CLASS_NAME}"
16+
workers:
17+
machineDeployments:
18+
- class: default-worker
19+
template:
20+
bootstrap:
21+
ref:
22+
name: "${CLUSTER_CLASS_NAME}-md-0"
23+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta2
24+
kind: EKSConfigTemplate
25+
infrastructure:
26+
ref:
27+
name: "${CLUSTER_CLASS_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_CLASS_NAME}"
35+
spec:
36+
template:
37+
spec: {}
38+
---
39+
kind: AWSManagedControlPlaneTemplate
40+
apiVersion: controlplane.cluster.x-k8s.io/v1beta2
41+
metadata:
42+
name: "${CLUSTER_CLASS_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_CLASS_NAME}-md-0"
54+
spec:
55+
template:
56+
spec:
57+
ami:
58+
eksLookupType: AmazonLinux2023
59+
cloudInit:
60+
insecureSkipSecretsManager: true
61+
instanceType: "${AWS_NODE_MACHINE_TYPE}"
62+
iamInstanceProfile: "nodes.cluster-api-provider-aws.sigs.k8s.io"
63+
sshKeyName: "${AWS_SSH_KEY_NAME}"
64+
---
65+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta2
66+
kind: NodeadmConfigTemplate
67+
metadata:
68+
name: "${CLUSTER_CLASS_NAME}-md-0"
69+
spec:
70+
template: {}

test/e2e/data/e2e_eks_conf.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ providers:
124124
targetName: "cluster-template-eks-auth-bootstrap-disabled.yaml"
125125
- sourcePath: "./infrastructure-aws/withclusterclass/kustomize_sources/eks-clusterclass/clusterclass-eks-e2e.yaml"
126126
- sourcePath: "./infrastructure-aws/withclusterclass/generated/cluster-template-eks-clusterclass.yaml"
127+
- sourcePath: "./infrastructure-aws/withclusterclass/kustomize_sources/eks-nodeadm-clusterclass/clusterclass-eks-nodeadm-e2e.yaml"
128+
- sourcePath: "./infrastructure-aws/withclusterclass/generated/cluster-template-eks-nodeadm-clusterclass.yaml"
127129

128130
variables:
129131
KUBERNETES_VERSION: "v1.32.0"
Lines changed: 17 additions & 0 deletions
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-nodeadm-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,73 @@
1+
apiVersion: cluster.x-k8s.io/v1beta1
2+
kind: ClusterClass
3+
metadata:
4+
name: eks-nodeadm-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: NodeadmConfigTemplate
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+
ami:
58+
eksLookupType: AmazonLinux2023
59+
cloudInit:
60+
insecureSkipSecretsManager: true
61+
instanceType: "${AWS_NODE_MACHINE_TYPE}"
62+
iamInstanceProfile: "nodes.cluster-api-provider-aws.sigs.k8s.io"
63+
sshKeyName: "${AWS_SSH_KEY_NAME}"
64+
---
65+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta2
66+
kind: NodeadmConfigTemplate
67+
metadata:
68+
name: "${CLUSTER_NAME}-md-0"
69+
spec:
70+
template: {}
71+
72+
73+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
resources:
2+
- cluster-template.yaml
3+
generatorOptions:
4+
disableNameSuffixHash: true
5+
labels:
6+
type: generated
7+
annotations:
8+
note: generated
9+
10+
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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+
"k8s.io/utils/ptr"
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+
capi_e2e "sigs.k8s.io/cluster-api/test/e2e"
33+
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
34+
"sigs.k8s.io/cluster-api/util"
35+
)
36+
37+
var _ = ginkgo.Describe("[managed] [general] [nodeadm] EKS nodeadm ClusterClass tests", func() {
38+
const specName = "cluster"
39+
var (
40+
ctx context.Context
41+
clusterName string
42+
)
43+
44+
ginkgo.BeforeEach(func() {
45+
ctx = context.TODO()
46+
47+
if !runGeneralTests() {
48+
ginkgo.Skip("skipping due to unmet condition")
49+
}
50+
51+
ginkgo.By("should have a valid test configuration")
52+
Expect(e2eCtx.Environment.BootstrapClusterProxy).ToNot(BeNil(), "BootstrapClusterProxy can't be nil")
53+
Expect(e2eCtx.E2EConfig).ToNot(BeNil(), "E2EConfig can't be nil")
54+
Expect(e2eCtx.E2EConfig.Variables).To(HaveKey(shared.KubernetesVersion))
55+
Expect(e2eCtx.E2EConfig.Variables).To(HaveKey(shared.CNIAddonVersion))
56+
57+
clusterName = fmt.Sprintf("%s-%s", specName, util.RandomString(6))
58+
59+
ginkgo.By("default iam role should exist")
60+
VerifyRoleExistsAndOwned(ctx, ekscontrolplanev1.DefaultEKSControlPlaneRole, "", false, e2eCtx.AWSSession)
61+
})
62+
63+
capi_e2e.QuickStartSpec(context.TODO(), func() capi_e2e.QuickStartSpecInput {
64+
return capi_e2e.QuickStartSpecInput{
65+
E2EConfig: e2eCtx.E2EConfig,
66+
ClusterctlConfigPath: e2eCtx.Environment.ClusterctlConfigPath,
67+
BootstrapClusterProxy: e2eCtx.Environment.BootstrapClusterProxy,
68+
ArtifactFolder: e2eCtx.Settings.ArtifactFolder,
69+
SkipCleanup: e2eCtx.Settings.SkipCleanup,
70+
Flavor: ptr.To(EKSNodeadmClusterClassFlavor),
71+
ClusterName: ptr.To(clusterName),
72+
WorkerMachineCount: ptr.To(int64(3)),
73+
ControlPlaneWaiters: clusterctl.ControlPlaneWaiters{
74+
WaitForControlPlaneInitialized: WaitForEKSControlPlaneInitialized,
75+
WaitForControlPlaneMachinesReady: WaitForEKSControlPlaneMachinesReady,
76+
},
77+
}
78+
})
79+
})

test/e2e/suites/managed/helpers.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ const (
5353
EKSClusterClassFlavor = "eks-clusterclass"
5454
EKSAuthAPIAndConfigMapFlavor = "eks-auth-api-and-config-map"
5555
EKSAuthBootstrapDisabledFlavor = "eks-auth-bootstrap-disabled"
56+
EKSNodeadmClusterClassFlavor = "eks-nodeadm-clusterclass"
5657
)
5758

5859
const (

0 commit comments

Comments
 (0)