Skip to content

Commit 3156e2e

Browse files
invidianDongsu Park
andcommitted
test/e2e: add tests for S3 Bucket and Flatcar support
Co-authored-by: Dongsu Park <[email protected]> Signed-off-by: Mateusz Gozdek <[email protected]>
1 parent bdc7ade commit 3156e2e

File tree

10 files changed

+136
-0
lines changed

10 files changed

+136
-0
lines changed

test/e2e/data/e2e_conf.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ providers:
232232
- sourcePath: "./infrastructure-aws/generated/cluster-template-internal-elb.yaml"
233233
- sourcePath: "./infrastructure-aws/kustomize_sources/topology/clusterclass-quick-start.yaml"
234234
- sourcePath: "./shared/v1beta1_provider/metadata.yaml"
235+
- sourcePath: "./infrastructure-aws/generated/cluster-template-ignition.yaml"
235236
replacements:
236237
# To allow bugs to be catched.
237238
- old: "failureThreshold: 3"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
resources:
2+
- ../default
3+
patchesStrategicMerge:
4+
- patches/control-plane-ami.yaml
5+
- patches/control-plane-ignition.yaml
6+
- patches/s3bucket.yaml
7+
- patches/worker-ami.yaml
8+
- patches/worker-ignition.yaml
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
2+
kind: AWSMachineTemplate
3+
metadata:
4+
name: "${CLUSTER_NAME}-control-plane"
5+
spec:
6+
template:
7+
spec:
8+
imageLookupBaseOS: flatcar-stable
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
2+
kind: KubeadmControlPlane
3+
metadata:
4+
name: "${CLUSTER_NAME}-control-plane"
5+
spec:
6+
kubeadmConfigSpec:
7+
initConfiguration:
8+
nodeRegistration:
9+
kubeletExtraArgs:
10+
cloud-provider: aws
11+
name: $${COREOS_EC2_HOSTNAME}
12+
joinConfiguration:
13+
nodeRegistration:
14+
kubeletExtraArgs:
15+
cloud-provider: aws
16+
name: $${COREOS_EC2_HOSTNAME}
17+
format: ignition
18+
ignition:
19+
containerLinuxConfig:
20+
additionalConfig: |
21+
systemd:
22+
units:
23+
- name: kubeadm.service
24+
enabled: true
25+
dropins:
26+
- name: 10-flatcar.conf
27+
contents: |
28+
[Unit]
29+
# kubeadm must run after coreos-metadata populated /run/metadata directory.
30+
Requires=coreos-metadata.service
31+
After=coreos-metadata.service
32+
[Service]
33+
# To make metadata environment variables available for pre-kubeadm commands.
34+
EnvironmentFile=/run/metadata/*
35+
preKubeadmCommands:
36+
- envsubst < /etc/kubeadm.yml > /etc/kubeadm.yml.tmp
37+
- mv /etc/kubeadm.yml.tmp /etc/kubeadm.yml
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
2+
kind: AWSCluster
3+
metadata:
4+
name: "${CLUSTER_NAME}"
5+
spec:
6+
s3Bucket:
7+
controlPlaneIAMInstanceProfile: control-plane.cluster-api-provider-aws.sigs.k8s.io
8+
# Letter at the end ensures bucket name ends with a letter which is a requirement.
9+
name: "cluster-api-provider-aws-${CLUSTER_NAME}a"
10+
nodesIAMInstanceProfiles:
11+
- nodes.cluster-api-provider-aws.sigs.k8s.io
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
2+
kind: AWSMachineTemplate
3+
metadata:
4+
name: "${CLUSTER_NAME}-md-0"
5+
spec:
6+
template:
7+
spec:
8+
imageLookupBaseOS: flatcar-stable
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
2+
kind: KubeadmConfigTemplate
3+
metadata:
4+
name: "${CLUSTER_NAME}-md-0"
5+
spec:
6+
template:
7+
spec:
8+
joinConfiguration:
9+
nodeRegistration:
10+
kubeletExtraArgs:
11+
cloud-provider: aws
12+
name: $${COREOS_EC2_HOSTNAME}
13+
format: ignition
14+
ignition:
15+
containerLinuxConfig:
16+
additionalConfig: |
17+
systemd:
18+
units:
19+
- name: kubeadm.service
20+
enabled: true
21+
dropins:
22+
- name: 10-flatcar.conf
23+
contents: |
24+
[Unit]
25+
# kubeadm must run after coreos-metadata populated /run/metadata directory.
26+
Requires=coreos-metadata.service
27+
After=coreos-metadata.service
28+
[Service]
29+
# To make metadata environment variables available for pre-kubeadm commands.
30+
EnvironmentFile=/run/metadata/*
31+
preKubeadmCommands:
32+
- envsubst < /etc/kubeadm.yml > /etc/kubeadm.yml.tmp
33+
- mv /etc/kubeadm.yml.tmp /etc/kubeadm.yml

test/e2e/shared/defaults.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const (
5454
SimpleMultitenancyFlavor = "simple-multitenancy"
5555
NestedMultitenancyFlavor = "nested-multitenancy"
5656
KCPScaleInFlavor = "kcp-scale-in"
57+
IgnitionFlavor = "ignition"
5758
StorageClassOutTreeZoneLabel = "topology.ebs.csi.aws.com/zone"
5859
GPUFlavor = "gpu"
5960
InstanceVcpu = "AWS_MACHINE_TYPE_VCPU_USAGE"

test/e2e/shared/template.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ func newBootstrapTemplate(e2eCtx *E2EContext) *cfn_bootstrap.Template {
105105
t.Spec.EKS.AllowIAMRoleCreation = false
106106
t.Spec.EKS.DefaultControlPlaneRole.Disable = false
107107
t.Spec.EKS.ManagedMachinePool.Disable = false
108+
t.Spec.S3Buckets.Enable = true
108109
str, err := yaml.Marshal(t.Spec)
109110
Expect(err).NotTo(HaveOccurred())
110111
Expect(os.WriteFile(path.Join(e2eCtx.Settings.ArtifactFolder, "awsiamconfiguration.yaml"), str, 0644)).To(Succeed()) //nolint:gosec

test/e2e/suites/unmanaged/unmanaged_functional_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,34 @@ var _ = ginkgo.Context("[unmanaged] [functional]", func() {
10441044
}
10451045
})
10461046
})
1047+
1048+
ginkgo.Describe("Workload cluster with AWS S3 and Ignition parameter", func() {
1049+
ginkgo.It("It should be creatable and deletable", func() {
1050+
specName := "functional-test-ignition-parameter"
1051+
namespace := shared.SetupSpecNamespace(ctx, specName, e2eCtx)
1052+
ginkgo.By("Creating a cluster")
1053+
clusterName := fmt.Sprintf("cluster-%s", util.RandomString(6))
1054+
configCluster := defaultConfigCluster(clusterName, namespace.Name)
1055+
configCluster.ControlPlaneMachineCount = pointer.Int64Ptr(1)
1056+
configCluster.WorkerMachineCount = pointer.Int64Ptr(1)
1057+
configCluster.Flavor = shared.IgnitionFlavor
1058+
_, md, _ := createCluster(ctx, configCluster, result)
1059+
1060+
workerMachines := framework.GetMachinesByMachineDeployments(ctx, framework.GetMachinesByMachineDeploymentsInput{
1061+
Lister: e2eCtx.Environment.BootstrapClusterProxy.GetClient(),
1062+
ClusterName: clusterName,
1063+
Namespace: namespace.Name,
1064+
MachineDeployment: *md[0],
1065+
})
1066+
controlPlaneMachines := framework.GetControlPlaneMachinesByCluster(ctx, framework.GetControlPlaneMachinesByClusterInput{
1067+
Lister: e2eCtx.Environment.BootstrapClusterProxy.GetClient(),
1068+
ClusterName: clusterName,
1069+
Namespace: namespace.Name,
1070+
})
1071+
Expect(len(workerMachines)).To(Equal(1))
1072+
Expect(len(controlPlaneMachines)).To(Equal(1))
1073+
})
1074+
})
10471075
})
10481076

10491077
func createStatefulSetInfo(isIntreeCSI bool, prefix string) statefulSetInfo {

0 commit comments

Comments
 (0)