Skip to content

Commit ae4993d

Browse files
Use fleet to deploy CNI across all providers
Signed-off-by: Danil-Grigorev <[email protected]>
1 parent 4b8c59f commit ae4993d

File tree

13 files changed

+65
-4762
lines changed

13 files changed

+65
-4762
lines changed

Diff for: examples/applications/cni/calico/helm-chart.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ spec:
3838
- vsphere-kubeadm-example
3939
- docker-kubeadm-example
4040
- docker-rke2-example
41+
- etcd-snapshot-restore

Diff for: test/e2e/data/cni/kindnet.yaml renamed to examples/applications/cni/kindnet/kindnet.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
kind: Bundle
33
apiVersion: fleet.cattle.io/v1alpha1
44
metadata:
5-
name: kindnet-cni-${CLUSTER_NAME}
5+
name: kindnet-cni
66
spec:
77
resources:
88
# List of all resources that will be deployed

Diff for: examples/examples.go

+3
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,7 @@ var (
3939

4040
//go:embed applications/ccm/vsphere/helm-chart.yaml
4141
CAPIVsphereCPIHelmApp []byte
42+
43+
//go:embed applications/cni/kindnet/kindnet.yaml
44+
CAPIKindnet []byte
4245
)

Diff for: test/e2e/const.go

-9
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,9 @@ var (
114114
//go:embed data/cluster-templates/vsphere-rke2-topology.yaml
115115
CAPIvSphereRKE2Topology []byte
116116

117-
//go:embed data/cni/kindnet.yaml
118-
CAPIKindnet []byte
119-
120-
//go:embed data/cni/calico.yaml
121-
CAPICalico []byte
122-
123117
//go:embed data/cpi-csi/aws.yaml
124118
CAPIAWSCPICSI []byte
125119

126-
//go:embed data/cluster-api-addon-provider-fleet/host-network-patch.yaml
127-
AddonProviderFleetHostNetworkPatch []byte
128-
129120
//go:embed data/gitea/ingress.yaml
130121
GiteaIngress []byte
131122

Diff for: test/e2e/data/cluster-api-addon-provider-fleet/host-network-patch.yaml

-7
This file was deleted.

Diff for: test/e2e/data/cluster-templates/docker-rke2.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ metadata:
66
annotations:
77
cluster-api.cattle.io/upstream-system-agent: "true"
88
labels:
9-
cni: kindnet
9+
cni: calico
1010
spec:
1111
clusterNetwork:
1212
pods:

Diff for: test/e2e/data/cni/calico.yaml

-4,731
This file was deleted.

Diff for: test/e2e/specs/etcd_snapshot_restore.go

+12
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ type ETCDSnapshotRestoreInput struct {
7676

7777
SkipCleanup bool `env:"SKIP_RESOURCE_CLEANUP"`
7878
SkipDeletionTest bool `env:"SKIP_DELETION_TEST"`
79+
80+
// AdditionalFleetGitRepos specifies additional FleetGitRepos to be created before the main GitRepo.
81+
// This is useful for setting up resources like cluster classes/cni/cpi that some tests require.
82+
AdditionalFleetGitRepos []turtlesframework.FleetCreateGitRepoInput
7983
}
8084

8185
// CreateUsingGitOpsSpec implements a spec that will create a cluster via Fleet and test that it
@@ -174,6 +178,14 @@ func ETCDSnapshotRestore(ctx context.Context, inputGetter func() ETCDSnapshotRes
174178
workerMachineCount = *input.WorkerMachineCount
175179
}
176180

181+
for _, additionalRepo := range input.AdditionalFleetGitRepos {
182+
if additionalRepo.TargetClusterNamespace {
183+
additionalRepo.TargetNamespace = namespace.Name
184+
}
185+
186+
turtlesframework.FleetCreateGitRepo(ctx, additionalRepo)
187+
}
188+
177189
turtlesframework.AddLabelsToNamespace(ctx, turtlesframework.AddLabelsToNamespaceInput{ // Set import label to trigger fleet installation
178190
ClusterProxy: input.BootstrapClusterProxy,
179191
Name: namespace.Name,

Diff for: test/e2e/specs/import_gitops_mgmtv3.go

+4
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ func CreateMgmtV3UsingGitOpsSpec(ctx context.Context, inputGetter func() CreateM
235235
}
236236

237237
for _, additionalRepo := range input.AdditionalFleetGitRepos {
238+
if additionalRepo.TargetClusterNamespace {
239+
additionalRepo.TargetNamespace = namespace.Name
240+
}
241+
238242
turtlesframework.FleetCreateGitRepo(ctx, additionalRepo)
239243
}
240244

Diff for: test/e2e/suites/etcd-snapshot-restore/etcd_snapshot_restore_test.go

+12-4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828

2929
"github.com/rancher/turtles/test/e2e"
3030
"github.com/rancher/turtles/test/e2e/specs"
31+
turtlesframework "github.com/rancher/turtles/test/framework"
3132
)
3233

3334
var _ = Describe("[Docker] [RKE2] Perform an ETCD backup and restore of the cluster", Label(e2e.ShortTestLabel), func() {
@@ -38,10 +39,17 @@ var _ = Describe("[Docker] [RKE2] Perform an ETCD backup and restore of the clus
3839

3940
specs.ETCDSnapshotRestore(ctx, func() specs.ETCDSnapshotRestoreInput {
4041
return specs.ETCDSnapshotRestoreInput{
41-
E2EConfig: e2e.LoadE2EConfig(),
42-
BootstrapClusterProxy: bootstrapClusterProxy,
43-
ClusterTemplate: e2e.CAPIDockerRKE2,
44-
AdditionalTemplates: [][]byte{e2e.CAPIKindnet},
42+
E2EConfig: e2e.LoadE2EConfig(),
43+
BootstrapClusterProxy: bootstrapClusterProxy,
44+
ClusterTemplate: e2e.CAPIDockerRKE2,
45+
AdditionalFleetGitRepos: []turtlesframework.FleetCreateGitRepoInput{
46+
{
47+
Name: "etcd-snapshot-restore-calico",
48+
Paths: []string{"examples/applications/cni/calico"},
49+
ClusterProxy: bootstrapClusterProxy,
50+
TargetClusterNamespace: true,
51+
},
52+
},
4553
ClusterName: "etcd-snapshot-restore",
4654
ControlPlaneMachineCount: ptr.To[int](1),
4755
WorkerMachineCount: ptr.To[int](0),

Diff for: test/e2e/suites/import-gitops-v3/import_gitops_v3_test.go

+12-5
Original file line numberDiff line numberDiff line change
@@ -335,10 +335,18 @@ var _ = Describe("[AWS] [EC2 Kubeadm] Create and delete CAPI cluster functionali
335335
})
336336

337337
return specs.CreateMgmtV3UsingGitOpsSpecInput{
338-
E2EConfig: e2e.LoadE2EConfig(),
339-
BootstrapClusterProxy: bootstrapClusterProxy,
340-
ClusterTemplate: e2e.CAPIAwsEC2Kubeadm,
341-
AdditionalTemplates: [][]byte{e2e.CAPICalico, e2e.CAPIAWSCPICSI},
338+
E2EConfig: e2e.LoadE2EConfig(),
339+
BootstrapClusterProxy: bootstrapClusterProxy,
340+
ClusterTemplate: e2e.CAPIAwsEC2Kubeadm,
341+
AdditionalTemplates: [][]byte{e2e.CAPIAWSCPICSI},
342+
AdditionalFleetGitRepos: []turtlesframework.FleetCreateGitRepoInput{
343+
{
344+
Name: "calico",
345+
Paths: []string{"examples/applications/cni/calico"},
346+
ClusterProxy: bootstrapClusterProxy,
347+
TargetClusterNamespace: true,
348+
},
349+
},
342350
ClusterName: "cluster-ec2",
343351
ControlPlaneMachineCount: ptr.To(1),
344352
WorkerMachineCount: ptr.To(1),
@@ -432,7 +440,6 @@ var _ = Describe("[vSphere] [Kubeadm] Create and delete CAPI cluster from cluste
432440
E2EConfig: e2e.LoadE2EConfig(),
433441
BootstrapClusterProxy: bootstrapClusterProxy,
434442
ClusterTemplate: e2e.CAPIvSphereKubeadmTopology,
435-
AdditionalTemplates: [][]byte{e2e.CAPICalico},
436443
ClusterName: "cluster-vsphere-kubeadm",
437444
ControlPlaneMachineCount: ptr.To(1),
438445
WorkerMachineCount: ptr.To(1),

Diff for: test/framework/fleet_helper.go

+12
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,18 @@ type FleetCreateGitRepoInput struct {
4646
// TargetNamespace is the namespace in which the Git repository will apply its content.
4747
TargetNamespace string
4848

49+
// TargetClusterNamespace is defining git repo to use cluster namespace as a target namespace by default.
50+
TargetClusterNamespace bool
51+
4952
// Repo is the URL of the Git repository.
5053
Repo string
5154

5255
// Branch is the branch of the Git repository to use.
5356
Branch string `envDefault:"main"`
5457

58+
// Revision is the specific commit of the Git repository to use.
59+
Revision string `env:"GITHUB_SHA"`
60+
5561
// Paths are the paths within the Git repository to sync.
5662
Paths []string
5763

@@ -191,7 +197,13 @@ metadata:
191197
namespace: {{ .Namespace }}
192198
spec:
193199
repo: {{ .Repo }}
200+
{{- if .Branch }}
194201
branch: {{ .Branch }}
202+
{{ end -}}
203+
{{- if .Revision }}
204+
revision: {{ .Revision }}
205+
{{ end -}}
206+
195207
forceSyncGeneration: {{ .FleetGeneration }}
196208
197209
paths:

Diff for: test/framework/git_helper.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,17 @@ func defaultToCurrentGitRepo(input *FleetCreateGitRepoInput) {
173173
}
174174
input.Repo = httpURL
175175

176-
// Get the current branch
177-
head, err := repo.Head()
178-
Expect(err).ShouldNot(HaveOccurred(), fmt.Sprintf("failed to get HEAD: %w", err))
176+
if input.Revision == "" {
177+
// Get the current branch
178+
head, err := repo.Head()
179+
Expect(err).ShouldNot(HaveOccurred(), fmt.Sprintf("failed to get HEAD: %w", err))
179180

180-
input.Branch = head.Name().Short()
181+
input.Branch = head.Name().Short()
182+
}
181183

182184
// Unset secret name to use public repository
183185
input.ClientSecretName = ""
186+
184187
return
185188
}
186189
}

0 commit comments

Comments
 (0)