Skip to content

Commit

Permalink
Add RKE2 boostrap provider to e2e
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandr Demicev <alexandr.demicev@suse.com>
  • Loading branch information
alexander-demicev committed Oct 2, 2023
1 parent 2969dc0 commit ddb8cc2
Show file tree
Hide file tree
Showing 4 changed files with 184 additions and 3 deletions.
32 changes: 31 additions & 1 deletion test/e2e/data/capi-operator/full-providers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,34 @@ metadata:
namespace: capa-system
spec:
secretName: full-variables
secretNamespace: default
secretNamespace: default
---
apiVersion: v1
kind: Namespace
metadata:
name: rke2-bootstrap-system
---
apiVersion: operator.cluster.x-k8s.io/v1alpha1
kind: BootstrapProvider
metadata:
name: bootstrap-caprke2
namespace: rke2-bootstrap-system
spec:
fetchConfig:
url: https://github.com/rancher-sandbox/cluster-api-provider-rke2/releases/v0.1.1/bootstrap-components.yaml
version: v0.1.1
---
apiVersion: v1
kind: Namespace
metadata:
name: rke2-control-plane-system
---
apiVersion: operator.cluster.x-k8s.io/v1alpha1
kind: ControlPlaneProvider
metadata:
name: control-plane-caprke2
namespace: rke2-control-plane-system
spec:
fetchConfig:
url: https://github.com/rancher-sandbox/cluster-api-provider-rke2/releases/v0.1.1/control-plane-components.yaml
version: v0.1.1
99 changes: 99 additions & 0 deletions test/e2e/data/cluster-templates/docker-rke2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: DockerCluster
metadata:
name: ${CLUSTER_NAME}
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
name: ${CLUSTER_NAME}
spec:
clusterNetwork:
pods:
cidrBlocks:
- 10.45.0.0/16
services:
cidrBlocks:
- 10.46.0.0/16
serviceDomain: cluster.local
controlPlaneRef:
apiVersion: controlplane.cluster.x-k8s.io/v1alpha1
kind: RKE2ControlPlane
name: ${CLUSTER_NAME}-control-plane
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: DockerCluster
name: ${CLUSTER_NAME}
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: DockerMachineTemplate
metadata:
name: ${CLUSTER_NAME}-control-plane
spec:
template:
spec:
customImage: rke2-ubuntu:${KUBERNETES_VERSION}-rke2r1
extraMounts:
- containerPath: /var/run/docker.sock
hostPath: /var/run/docker.sock
---
apiVersion: controlplane.cluster.x-k8s.io/v1alpha1
kind: RKE2ControlPlane
metadata:
name: ${CLUSTER_NAME}-control-plane
spec:
agentConfig:
version: ${KUBERNETES_VERSION}+rke2r1
airGapped: true
serverConfig:
cni: calico
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: DockerMachineTemplate
name: ${CLUSTER_NAME}-control-plane
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
nodeDrainTimeout: 2m
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: DockerMachineTemplate
metadata:
name: ${CLUSTER_NAME}-md-0
spec:
template:
spec:
customImage: rke2-ubuntu:${KUBERNETES_VERSION}-rke2r1
---
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha1
kind: RKE2ConfigTemplate
metadata:
name: ${CLUSTER_NAME}-md-0
spec:
template:
spec:
agentConfig:
version: ${KUBERNETES_VERSION}+rke2r1
airGapped: true
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
name: worker-md-0
spec:
clusterName: ${CLUSTER_NAME}
replicas: ${WORKER_MACHINE_COUNT}
selector:
matchLabels:
cluster.x-k8s.io/cluster-name: ${CLUSTER_NAME}
template:
spec:
version: ${KUBERNETES_VERSION}
clusterName: ${CLUSTER_NAME}
bootstrap:
configRef:
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha1
kind: RKE2ConfigTemplate
name: ${CLUSTER_NAME}-md-0
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: DockerMachineTemplate
name: ${CLUSTER_NAME}-md-0
27 changes: 25 additions & 2 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,14 @@ func initRancherTurtles(clusterProxy framework.ClusterProxy, config *clusterctl.
"-n", rancherTurtlesNamespace,
"--create-namespace", "--wait"),
}

Expect(config.Images).To(HaveLen(1))
imageNameTag := strings.Split(config.Images[0].Name, ":")
Expect(imageNameTag).To(HaveLen(2))

_, err := chart.Run(map[string]string{
"rancherTurtles.image": "ghcr.io/rancher-sandbox/rancher-turtles-amd64",
"rancherTurtles.tag": "v0.0.1",
"rancherTurtles.image": imageNameTag[0],
"rancherTurtles.tag": imageNameTag[1],
"rancherTurtles.managerArguments[0]": "--insecure-skip-verify=true",
"cluster-api-operator.cluster-api.configSecret.namespace": "default",
"cluster-api-operator.cluster-api.configSecret.name": "variables",
Expand Down Expand Up @@ -378,6 +383,24 @@ func initRancherTurtles(clusterProxy framework.ClusterProxy, config *clusterctl.
Namespace: "capa-system",
}},
}, config.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)

By("Waiting for CAPI RKE2 bootstrap provider deployment to be available")
framework.WaitForDeploymentsAvailable(ctx, framework.WaitForDeploymentsAvailableInput{
Getter: bootstrapClusterProxy.GetClient(),
Deployment: &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{
Name: "rke2-bootstrap-controller-manager",
Namespace: "rke2-bootstrap-system",
}},
}, config.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)

By("Waiting for CAPI RKE2 control plane provider deployment to be available")
framework.WaitForDeploymentsAvailable(ctx, framework.WaitForDeploymentsAvailableInput{
Getter: bootstrapClusterProxy.GetClient(),
Deployment: &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{
Name: "rke2-control-plane-controller-manager",
Namespace: "rke2-control-plane-system",
}},
}, config.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
}

func initRancher(clusterProxy framework.ClusterProxy, config *clusterctl.E2EConfig) {
Expand Down
29 changes: 29 additions & 0 deletions test/e2e/import_gitops_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,32 @@ var _ = Describe("[AWS] [EKS] Create and delete CAPI cluster functionality shoul
}
})
})

var _ = Describe("[Docker] [RKE2] Create and delete CAPI cluster functionality should work with namespace auto-import", Label(fullTestLabel), func() {
BeforeEach(func() {
SetClient(bootstrapClusterProxy.GetClient())
SetContext(ctx)
})

CreateUsingGitOpsSpec(ctx, func() CreateUsingGitOpsSpecInput {
return CreateUsingGitOpsSpecInput{
E2EConfig: e2eConfig,
BootstrapClusterProxy: bootstrapClusterProxy,
ClusterctlConfigPath: clusterctlConfigPath,
ClusterctlBinaryPath: clusterctlBinaryPath,
ArtifactFolder: artifactFolder,
ClusterTemplatePath: "./data/cluster-templates/docker-rke2.yaml",
ClusterName: "cluster3",
ControlPlaneMachineCount: ptr.To[int](1),
WorkerMachineCount: ptr.To[int](1),
GitAddr: gitAddress,
GitAuthSecretName: authSecretName,
SkipCleanup: false,
SkipDeletionTest: false,
LabelNamespace: true,
RancherServerURL: hostName,
CAPIClusterCreateWaitName: "wait-rancher",
DeleteClusterWaitName: "wait-controllers",
}
})
})

0 comments on commit ddb8cc2

Please sign in to comment.