Skip to content

Commit

Permalink
Add e2e test for custom subnet
Browse files Browse the repository at this point in the history
Signed-off-by: Shaad7 <abdullah.alshaad@appscode.com>
  • Loading branch information
AbdullahAlShaad committed Aug 17, 2023
1 parent e5e0c02 commit c26ce0a
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/e2e/config/gcp-ci.yaml
Expand Up @@ -71,6 +71,7 @@ providers:
- sourcePath: "${PWD}/test/e2e/data/infrastructure-gcp/cluster-template-ci-with-creds.yaml"
- sourcePath: "${PWD}/test/e2e/data/infrastructure-gcp/cluster-template-ci-gke.yaml"
- sourcePath: "${PWD}/test/e2e/data/infrastructure-gcp/cluster-template-ci-gke-autopilot.yaml"
- sourcePath: "${PWD}/test/e2e/data/infrastructure-gcp/cluster-template-ci-gke-custom-subnet.yaml"

variables:
KUBERNETES_VERSION: "${KUBERNETES_VERSION:-v1.25.7}"
Expand Down
@@ -0,0 +1,68 @@
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
name: "${CLUSTER_NAME}"
spec:
clusterNetwork:
pods:
cidrBlocks: ["192.168.0.0/16"]
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPManagedCluster
name: "${CLUSTER_NAME}"
controlPlaneRef:
kind: GCPManagedControlPlane
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
name: "${CLUSTER_NAME}-control-plane"
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPManagedCluster
metadata:
name: "${CLUSTER_NAME}"
spec:
project: "${GCP_PROJECT}"
region: "${GCP_REGION}"
network:
name: "${GCP_NETWORK_NAME}"
autoCreateSubnetworks: false
subnets:
- name: "${GCP_SUBNET_NAME}"
cidrBlock: "${GCP_SUBNET_CIDR}"
region: {"$GCP_REGION"}
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPManagedControlPlane
metadata:
name: "${CLUSTER_NAME}-control-plane"
spec:
project: "${GCP_PROJECT}"
location: "${GCP_REGION}"
releaseChannel: "regular"
---
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachinePool
metadata:
name: ${CLUSTER_NAME}-mp-0
spec:
clusterName: ${CLUSTER_NAME}
replicas: ${WORKER_MACHINE_COUNT}
template:
spec:
bootstrap:
dataSecretName: ""
clusterName: ${CLUSTER_NAME}
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPManagedMachinePool
name: ${CLUSTER_NAME}-mp-0
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: GCPManagedMachinePool
metadata:
name: ${CLUSTER_NAME}-mp-0
spec:
scaling:
minCount: ${GKE_MACHINE_POOL_MIN}
maxCount: ${GKE_MACHINE_POOL_MAX}

29 changes: 29 additions & 0 deletions test/e2e/e2e_test.go
Expand Up @@ -182,4 +182,33 @@ var _ = Describe("Workload cluster creation", func() {
}, result)
})
})

Context("Creating a single control-plane cluster", func() {
It("Should create a cluster with 1 worker node and can be scaled", func() {
By("Initializes with 1 worker node")
clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
ClusterProxy: bootstrapClusterProxy,
ConfigCluster: clusterctl.ConfigClusterInput{
LogFolder: clusterctlLogFolder,
ClusterctlConfigPath: clusterctlConfigPath,
KubeconfigPath: bootstrapClusterProxy.GetKubeconfigPath(),
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
Flavor: clusterctl.DefaultFlavor,
Namespace: namespace.Name,
ClusterName: clusterName,
KubernetesVersion: e2eConfig.GetVariable(KubernetesVersion),
ControlPlaneMachineCount: pointer.Int64Ptr(1),
WorkerMachineCount: pointer.Int64Ptr(1),
ClusterctlVariables: map[string]string{
"GCP_SUBNET_NAME": "capg-test-subnet",
"GCP_SUBNET_CIDR": "172.20.0.0/16",
},
},
WaitForClusterIntervals: e2eConfig.GetIntervals(specName, "wait-cluster"),
WaitForControlPlaneIntervals: e2eConfig.GetIntervals(specName, "wait-control-plane"),
WaitForMachineDeployments: e2eConfig.GetIntervals(specName, "wait-worker-nodes"),
}, result)

})
})
})

0 comments on commit c26ce0a

Please sign in to comment.