Skip to content

WIP: feat: add capa+cabpk clusterclass example and test #1290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,58 +1,23 @@
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
labels:
cni: calico
ccm: external
csi: external
name: ${CLUSTER_NAME}
namespace: ${NAMESPACE}
spec:
clusterNetwork:
pods:
cidrBlocks:
- 192.168.0.0/16
topology:
class: ${CLUSTER_NAME}
controlPlane:
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
variables:
- name: region
value: ${AWS_REGION}
- name: sshKeyName
value: ${AWS_SSH_KEY_NAME}
- name: controlPlaneMachineType
value: ${AWS_CONTROL_PLANE_MACHINE_TYPE}
- name: workerMachineType
value: ${AWS_NODE_MACHINE_TYPE}
version: ${KUBERNETES_VERSION}
workers:
machineDeployments:
- class: default-worker
name: md-0
replicas: ${WORKER_MACHINE_COUNT}
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: ClusterClass
metadata:
name: ${CLUSTER_NAME}
namespace: ${NAMESPACE}
name: aws-kubeadm-example
spec:
controlPlane:
ref:
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: KubeadmControlPlaneTemplate
name: ${CLUSTER_NAME}-control-plane
name: aws-kubeadm-example-control-plane
machineInfrastructure:
ref:
kind: AWSMachineTemplate
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
name: ${CLUSTER_NAME}-control-plane
name: aws-kubeadm-example-control-plane
infrastructure:
ref:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: AWSClusterTemplate
name: ${CLUSTER_NAME}
name: aws-kubeadm-example
workers:
machineDeployments:
- class: default-worker
Expand All @@ -61,12 +26,12 @@ spec:
ref:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
name: ${CLUSTER_NAME}-worker-bootstraptemplate
name: aws-kubeadm-example-worker-bootstraptemplate
infrastructure:
ref:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: AWSMachineTemplate
name: ${CLUSTER_NAME}-worker-machinetemplate
name: aws-kubeadm-example-worker-machinetemplate
variables:
- name: region
required: true
Expand Down Expand Up @@ -160,20 +125,33 @@ spec:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: AWSClusterTemplate
metadata:
name: ${CLUSTER_NAME}
namespace: ${NAMESPACE}
name: aws-kubeadm-example
spec:
template:
spec:
network:
cni:
cniIngressRules:
- description: BGP
fromPort: 179
protocol: tcp
toPort: 179
- description: IP-in-IP
fromPort: -1
protocol: 4
toPort: 65535
- description: Calico Typha
fromPort: 5473
protocol: tcp
toPort: 5473
controlPlaneLoadBalancer:
loadBalancerType: nlb
healthCheckProtocol: HTTPS
---
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: KubeadmControlPlaneTemplate
metadata:
name: ${CLUSTER_NAME}-control-plane
namespace: ${NAMESPACE}
name: aws-kubeadm-example-control-plane
spec:
template:
spec:
Expand All @@ -199,8 +177,7 @@ spec:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: AWSMachineTemplate
metadata:
name: ${CLUSTER_NAME}-control-plane
namespace: ${NAMESPACE}
name: aws-kubeadm-example-control-plane
spec:
template:
spec:
Expand All @@ -213,8 +190,7 @@ spec:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: AWSMachineTemplate
metadata:
name: ${CLUSTER_NAME}-worker-machinetemplate
namespace: ${NAMESPACE}
name: aws-kubeadm-example-worker-machinetemplate
spec:
template:
spec:
Expand All @@ -227,8 +203,7 @@ spec:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
metadata:
name: "${CLUSTER_NAME}-worker-bootstraptemplate"
namespace: ${NAMESPACE}
name: "aws-kubeadm-example-worker-bootstraptemplate"
spec:
template:
spec:
Expand All @@ -237,45 +212,3 @@ spec:
kubeletExtraArgs:
cloud-provider: external
name: '{{ ds.meta_data.local_hostname }}'
---
apiVersion: addons.cluster.x-k8s.io/v1beta1
kind: ClusterResourceSet
metadata:
name: crs-cni
namespace: ${NAMESPACE}
spec:
clusterSelector:
matchLabels:
cni: calico
resources:
- kind: ConfigMap
name: calico-cni
strategy: ApplyOnce
---
apiVersion: addons.cluster.x-k8s.io/v1beta1
kind: ClusterResourceSet
metadata:
name: crs-ccm
namespace: ${NAMESPACE}
spec:
clusterSelector:
matchLabels:
ccm: external
resources:
- kind: ConfigMap
name: cloud-controller-manager-addon
strategy: ApplyOnce
---
apiVersion: addons.cluster.x-k8s.io/v1beta1
kind: ClusterResourceSet
metadata:
name: crs-csi
namespace: ${NAMESPACE}
spec:
clusterSelector:
matchLabels:
csi: external
resources:
- kind: ConfigMap
name: aws-ebs-csi-driver-addon
strategy: ApplyOnce
6 changes: 3 additions & 3 deletions test/e2e/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ var (
//go:embed data/cluster-templates/aws-eks-mmp.yaml
CAPIAwsEKSMMP []byte

//go:embed data/cluster-templates/aws-ec2-kubeadm.yaml
CAPIAwsEC2Kubeadm []byte

//go:embed data/cluster-templates/aws-ec2-rke2-topology.yaml
CAPIAwsEC2RKE2Topology []byte

//go:embed data/cluster-templates/aws-kubeadm-topology.yaml
CAPIAwsKubeadmTopology []byte

//go:embed data/cluster-templates/gcp-gke.yaml
CAPIGCPGKE []byte

Expand Down
76 changes: 76 additions & 0 deletions test/e2e/data/cluster-templates/aws-kubeadm-topology.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
labels:
cni: calico
cloud-provider: aws
csi: aws-ebs-csi-driver
name: ${CLUSTER_NAME}
namespace: ${NAMESPACE}
spec:
clusterNetwork:
pods:
cidrBlocks:
- 192.168.0.0/16
topology:
class: aws-kubeadm-example
classNamespace: ${TOPOLOGY_NAMESPACE}
controlPlane:
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
variables:
- name: region
value: ${AWS_REGION}
- name: sshKeyName
value: ${AWS_SSH_KEY_NAME}
- name: controlPlaneMachineType
value: ${AWS_CONTROL_PLANE_MACHINE_TYPE}
- name: workerMachineType
value: ${AWS_NODE_MACHINE_TYPE}
version: ${KUBERNETES_VERSION}
workers:
machineDeployments:
- class: default-worker
name: md-0
replicas: ${WORKER_MACHINE_COUNT}
---
apiVersion: addons.cluster.x-k8s.io/v1beta1
kind: ClusterResourceSet
metadata:
name: crs-cni-aws-kubeadm
namespace: ${NAMESPACE}
spec:
clusterSelector:
matchLabels:
cni: calico
resources:
- kind: ConfigMap
name: calico-cni
strategy: ApplyOnce
---
apiVersion: addons.cluster.x-k8s.io/v1beta1
kind: ClusterResourceSet
metadata:
name: crs-ccm-aws-kubeadm
namespace: ${NAMESPACE}
spec:
clusterSelector:
matchLabels:
cloud-provider: aws
resources:
- kind: ConfigMap
name: cloud-controller-manager-addon
strategy: ApplyOnce
---
apiVersion: addons.cluster.x-k8s.io/v1beta1
kind: ClusterResourceSet
metadata:
name: crs-csi-aws-kubeadm
namespace: ${NAMESPACE}
spec:
clusterSelector:
matchLabels:
csi: aws-ebs-csi-driver
resources:
- kind: ConfigMap
name: aws-ebs-csi-driver-addon
strategy: ApplyOnce
34 changes: 20 additions & 14 deletions test/e2e/suites/import-gitops-v3/import_gitops_v3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,7 @@ var _ = Describe("[Docker] [RKE2] Create and delete CAPI cluster functionality s
})

var _ = Describe("[Azure] [AKS] Create and delete CAPI cluster from cluster class", Label(e2e.FullTestLabel), func() {
var (
topologyNamespace string
)
var topologyNamespace string

BeforeEach(func() {
komega.SetClient(bootstrapClusterProxy.GetClient())
Expand Down Expand Up @@ -199,9 +197,7 @@ var _ = Describe("[Azure] [AKS] Create and delete CAPI cluster from cluster clas
})

var _ = Describe("[Azure] [RKE2] - [management.cattle.io/v3] Create and delete CAPI cluster from cluster class", Label(e2e.FullTestLabel, e2e.Rke2TestLabel), func() {
var (
topologyNamespace string
)
var topologyNamespace string

BeforeEach(func() {
komega.SetClient(bootstrapClusterProxy.GetClient())
Expand Down Expand Up @@ -311,9 +307,13 @@ var _ = Describe("[AWS] [EKS] Create and delete CAPI cluster functionality shoul
})

var _ = Describe("[AWS] [EC2 Kubeadm] Create and delete CAPI cluster functionality should work with namespace auto-import", Label(e2e.FullTestLabel, e2e.KubeadmTestLabel), func() {
var topologyNamespace string

BeforeEach(func() {
komega.SetClient(bootstrapClusterProxy.GetClient())
komega.SetContext(ctx)

topologyNamespace = "creategitops-aws-kubeadm"
})

specs.CreateMgmtV3UsingGitOpsSpec(ctx, func() specs.CreateMgmtV3UsingGitOpsSpecInput {
Expand All @@ -337,12 +337,13 @@ var _ = Describe("[AWS] [EC2 Kubeadm] Create and delete CAPI cluster functionali
return specs.CreateMgmtV3UsingGitOpsSpecInput{
E2EConfig: e2e.LoadE2EConfig(),
BootstrapClusterProxy: bootstrapClusterProxy,
ClusterTemplate: e2e.CAPIAwsEC2Kubeadm,
ClusterTemplate: e2e.CAPIAwsKubeadmTopology,
AdditionalTemplates: [][]byte{e2e.CAPICalico, e2e.CAPIAWSCPICSI},
ClusterName: "cluster-ec2",
ClusterName: "cluster-aws-kubeadm",
ControlPlaneMachineCount: ptr.To(1),
WorkerMachineCount: ptr.To(1),
GitAddr: gitAddress,
SkipDeletionTest: false,
LabelNamespace: true,
RancherServerURL: hostName,
CAPIClusterCreateWaitName: "wait-capa-create-cluster",
Expand All @@ -353,14 +354,21 @@ var _ = Describe("[AWS] [EC2 Kubeadm] Create and delete CAPI cluster functionali
AdditionalTemplateVariables: map[string]string{
e2e.KubernetesVersionVar: e2e.LoadE2EConfig().GetVariable(e2e.AWSKubernetesVersionVar), // override the default k8s version
},
TopologyNamespace: topologyNamespace,
AdditionalFleetGitRepos: []turtlesframework.FleetCreateGitRepoInput{
{
Name: "aws-cluster-classes-regular",
Paths: []string{"examples/clusterclasses/aws"},
ClusterProxy: bootstrapClusterProxy,
TargetNamespace: topologyNamespace,
},
},
}
})
})

var _ = Describe("[AWS] [EC2 RKE2] Create and delete CAPI cluster functionality should work with namespace auto-import", Label(e2e.FullTestLabel, e2e.Rke2TestLabel), func() {
var (
topologyNamespace string
)
var topologyNamespace string

BeforeEach(func() {
komega.SetClient(bootstrapClusterProxy.GetClient())
Expand Down Expand Up @@ -459,9 +467,7 @@ var _ = Describe("[GCP] [GKE] Create and delete CAPI cluster functionality shoul
})

var _ = Describe("[vSphere] [Kubeadm] Create and delete CAPI cluster from cluster class", Label(e2e.VsphereTestLabel, e2e.KubeadmTestLabel), func() {
var (
topologyNamespace string
)
var topologyNamespace string

BeforeEach(func() {
komega.SetClient(bootstrapClusterProxy.GetClient())
Expand Down
Loading