Skip to content

Commit 46065eb

Browse files
author
Winnie Kwon
committed
Add ssm test based on ClusterClass
1 parent 6494d84 commit 46065eb

File tree

5 files changed

+147
-68
lines changed

5 files changed

+147
-68
lines changed

test/e2e/data/infrastructure-aws/kustomize_sources/topology/cluster-template.yaml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,25 @@ spec:
1313
class: "quick-start"
1414
version: "${KUBERNETES_VERSION}"
1515
controlPlane:
16-
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
16+
replicas: "${CONTROL_PLANE_MACHINE_COUNT}"
1717
workers:
1818
machineDeployments:
1919
- class: "default-worker"
2020
name: "md-0"
21-
replicas: ${WORKER_MACHINE_COUNT}
21+
replicas: "${WORKER_MACHINE_COUNT}"
2222
variables:
2323
- name: region
24-
value: ${AWS_REGION}
24+
value: "${AWS_REGION}"
2525
- name: sshKeyName
26-
value: ${AWS_SSH_KEY_NAME}
26+
value: "${AWS_SSH_KEY_NAME}"
2727
- name: controlPlaneMachineType
28-
value: ${AWS_CONTROL_PLANE_MACHINE_TYPE}
28+
value: "${AWS_CONTROL_PLANE_MACHINE_TYPE}"
2929
- name: workerMachineType
30-
value: ${AWS_NODE_MACHINE_TYPE}
30+
value: "${AWS_NODE_MACHINE_TYPE}"
31+
- name: secureSecretsBackend
32+
value: "ssm-parameter-store"
33+
- name: healthCheckProtocol
34+
value: "TCP"
3135
---
3236
apiVersion: v1
3337
data: ${CNI_RESOURCES}

test/e2e/data/infrastructure-aws/kustomize_sources/topology/clusterclass-quick-start.yaml

Lines changed: 100 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -57,78 +57,115 @@ spec:
5757
openAPIV3Schema:
5858
type: string
5959
default: t3.large
60+
- name: secureSecretsBackend
61+
required: false
62+
schema:
63+
openAPIV3Schema:
64+
type: string
65+
default: secrets-manager
66+
- name: healthCheckProtocol
67+
required: false
68+
schema:
69+
openAPIV3Schema:
70+
type: string
71+
default: SSL
6072
patches:
61-
- name: region
73+
- name: awsClusterTemplateGeneral
6274
definitions:
63-
- selector:
64-
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
65-
kind: AWSClusterTemplate
66-
matchResources:
67-
infrastructureCluster: true
68-
jsonPatches:
69-
- op: add
70-
path: /spec/template/spec/region
71-
valueFrom:
72-
variable: region
73-
- name: sshKeyName
75+
- selector:
76+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
77+
kind: AWSClusterTemplate
78+
matchResources:
79+
infrastructureCluster: true
80+
jsonPatches:
81+
- op: add
82+
path: "/spec/template/spec/region"
83+
valueFrom:
84+
variable: region
85+
- op: add
86+
path: "/spec/template/spec/sshKeyName"
87+
valueFrom:
88+
variable: sshKeyName
89+
- name: awsMachineTemplateControlPlane
7490
definitions:
75-
- selector:
76-
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
77-
kind: AWSClusterTemplate
78-
matchResources:
79-
infrastructureCluster: true
80-
jsonPatches:
81-
- op: add
82-
path: /spec/template/spec/sshKeyName
83-
valueFrom:
84-
variable: sshKeyName
85-
- selector:
86-
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
87-
kind: AWSMachineTemplate
88-
matchResources:
89-
controlPlane: true
90-
machineDeploymentClass:
91-
names:
92-
- default-worker
93-
jsonPatches:
94-
- op: add
95-
path: /spec/template/spec/sshKeyName
96-
valueFrom:
97-
variable: sshKeyName
98-
- name: controlPlaneMachineType
91+
- selector:
92+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
93+
kind: AWSMachineTemplate
94+
matchResources:
95+
controlPlane: true
96+
jsonPatches:
97+
- op: replace
98+
path: "/spec/template/spec/instanceType"
99+
valueFrom:
100+
variable: controlPlaneMachineType
101+
- op: add
102+
path: "/spec/template/spec/sshKeyName"
103+
valueFrom:
104+
variable: sshKeyName
105+
- name: awsMachineTemplateWorker
99106
definitions:
100-
- selector:
101-
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
102-
kind: AWSMachineTemplate
103-
matchResources:
104-
controlPlane: true
105-
jsonPatches:
106-
- op: replace
107-
path: /spec/template/spec/instanceType
108-
valueFrom:
109-
variable: controlPlaneMachineType
110-
- name: workerMachineType
107+
- selector:
108+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
109+
kind: AWSMachineTemplate
110+
matchResources:
111+
machineDeploymentClass:
112+
names:
113+
- default-worker
114+
jsonPatches:
115+
- op: replace
116+
path: "/spec/template/spec/instanceType"
117+
valueFrom:
118+
variable: workerMachineType
119+
- op: add
120+
path: "/spec/template/spec/sshKeyName"
121+
valueFrom:
122+
variable: sshKeyName
123+
- name: secureSecretsBackend
124+
enabledIf: '{{if .secureSecretsBackend }}true{{end}}'
111125
definitions:
112-
- selector:
113-
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
114-
kind: AWSMachineTemplate
115-
matchResources:
116-
machineDeploymentClass:
117-
names:
118-
- default-worker
119-
jsonPatches:
120-
- op: replace
121-
path: /spec/template/spec/instanceType
122-
valueFrom:
123-
variable: workerMachineType
126+
- selector:
127+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
128+
kind: AWSMachineTemplate
129+
matchResources:
130+
controlPlane: true
131+
jsonPatches:
132+
- op: add
133+
path: "/spec/template/spec/cloudInit/secureSecretsBackend"
134+
valueFrom:
135+
variable: secureSecretsBackend
136+
- selector:
137+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
138+
kind: AWSMachineTemplate
139+
matchResources:
140+
machineDeploymentClass:
141+
names:
142+
- default-worker
143+
jsonPatches:
144+
- op: add
145+
path: "/spec/template/spec/cloudInit/secureSecretsBackend"
146+
valueFrom:
147+
variable: secureSecretsBackend
148+
- name: healthCheckProtocol
149+
enabledIf: '{{if .healthCheckProtocol }}true{{end}}'
150+
definitions:
151+
- selector:
152+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
153+
kind: AWSClusterTemplate
154+
matchResources:
155+
infrastructureCluster: true
156+
jsonPatches:
157+
- op: add
158+
path: "/spec/template/spec/controlPlaneLoadBalancer/healthCheckProtocol"
159+
valueFrom:
160+
variable: healthCheckProtocol
124161
---
125162
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
126163
kind: AWSClusterTemplate
127164
metadata:
128165
name: quick-start
129166
spec:
130167
template:
131-
spec: { }
168+
spec: {}
132169
---
133170
kind: KubeadmControlPlaneTemplate
134171
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
@@ -166,6 +203,7 @@ spec:
166203
# instanceType is a required field (OpenAPI schema).
167204
instanceType: REPLACEME
168205
iamInstanceProfile: "control-plane.cluster-api-provider-aws.sigs.k8s.io"
206+
cloudInit: {}
169207
---
170208
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
171209
kind: AWSMachineTemplate
@@ -177,11 +215,12 @@ spec:
177215
# instanceType is a required field (OpenAPI schema).
178216
instanceType: REPLACEME
179217
iamInstanceProfile: "nodes.cluster-api-provider-aws.sigs.k8s.io"
218+
cloudInit: {}
180219
---
181220
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
182221
kind: KubeadmConfigTemplate
183222
metadata:
184-
name: "quick-start-worker-bootstraptemplate"
223+
name: quick-start-worker-bootstraptemplate
185224
spec:
186225
template:
187226
spec:

test/e2e/shared/defaults.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const (
4949
LimitAzFlavor = "limit-az"
5050
SpotInstancesFlavor = "spot-instances"
5151
SSMFlavor = "ssm"
52+
TopologyFlavor = "topology"
5253
UpgradeToMain = "upgrade-to-main"
5354
ExternalCloudProvider = "external-cloud-provider"
5455
SimpleMultitenancyFlavor = "simple-multitenancy"

test/e2e/suites/unmanaged/unmanaged_CAPI_quick_clusterclass_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ var _ = ginkgo.Context("[unmanaged] [Cluster API Framework] [smoke] [PR-Blocking
6161
BootstrapClusterProxy: e2eCtx.Environment.BootstrapClusterProxy,
6262
ArtifactFolder: e2eCtx.Settings.ArtifactFolder,
6363
SkipCleanup: e2eCtx.Settings.SkipCleanup,
64-
Flavor: pointer.String("topology"),
64+
Flavor: pointer.String(shared.TopologyFlavor),
6565
}
6666
})
6767
ginkgo.AfterEach(func() {

test/e2e/suites/unmanaged/unmanaged_functional_clusterclass_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333

3434
infrav1 "sigs.k8s.io/cluster-api-provider-aws/api/v1beta1"
3535
"sigs.k8s.io/cluster-api-provider-aws/test/e2e/shared"
36+
"sigs.k8s.io/cluster-api/test/framework"
3637
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
3738
"sigs.k8s.io/cluster-api/util"
3839
)
@@ -90,4 +91,38 @@ var _ = ginkgo.Context("[unmanaged] [functional] [ClusterClass]", func() {
9091
ginkgo.By("PASSED!")
9192
})
9293
})
94+
95+
ginkgo.Describe("Workload cluster with AWS SSM Parameter as the Secret Backend [ClusterClass]", func() {
96+
ginkgo.It("should be creatable and deletable", func() {
97+
specName := "functional-test-ssm-parameter-store-clusterclass"
98+
requiredResources = &shared.TestResource{EC2Normal: 2 * e2eCtx.Settings.InstanceVCPU, IGW: 1, NGW: 1, VPC: 1, ClassicLB: 1, EIP: 3}
99+
requiredResources.WriteRequestedResources(e2eCtx, specName)
100+
Expect(shared.AcquireResources(requiredResources, config.GinkgoConfig.ParallelNode, flock.New(shared.ResourceQuotaFilePath))).To(Succeed())
101+
defer shared.ReleaseResources(requiredResources, config.GinkgoConfig.ParallelNode, flock.New(shared.ResourceQuotaFilePath))
102+
namespace := shared.SetupSpecNamespace(ctx, specName, e2eCtx)
103+
defer shared.DumpSpecResourcesAndCleanup(ctx, "", namespace, e2eCtx)
104+
105+
ginkgo.By("Creating a cluster")
106+
clusterName := fmt.Sprintf("cluster-%s", util.RandomString(6))
107+
configCluster := defaultConfigCluster(clusterName, namespace.Name)
108+
configCluster.ControlPlaneMachineCount = pointer.Int64Ptr(1)
109+
configCluster.WorkerMachineCount = pointer.Int64Ptr(1)
110+
configCluster.Flavor = shared.TopologyFlavor
111+
_, md, _ := createCluster(ctx, configCluster, result)
112+
113+
workerMachines := framework.GetMachinesByMachineDeployments(ctx, framework.GetMachinesByMachineDeploymentsInput{
114+
Lister: e2eCtx.Environment.BootstrapClusterProxy.GetClient(),
115+
ClusterName: clusterName,
116+
Namespace: namespace.Name,
117+
MachineDeployment: *md[0],
118+
})
119+
controlPlaneMachines := framework.GetControlPlaneMachinesByCluster(ctx, framework.GetControlPlaneMachinesByClusterInput{
120+
Lister: e2eCtx.Environment.BootstrapClusterProxy.GetClient(),
121+
ClusterName: clusterName,
122+
Namespace: namespace.Name,
123+
})
124+
Expect(len(workerMachines)).To(Equal(1))
125+
Expect(len(controlPlaneMachines)).To(Equal(1))
126+
})
127+
})
93128
})

0 commit comments

Comments
 (0)