Skip to content
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

WIP: Cluster API CLI driven deployment #826

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
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
33 changes: 33 additions & 0 deletions bootstrap/helm/cluster-api-cluster/tests/gcp_cluster_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
suite: test gcp cluster
templates:
- gcp/cluster.yaml
tests:
- it: should be created with default values when provider is gcp
set:
provider: gcp
type: managed
asserts:
- hasDocuments:
count: 1
- isKind:
of: GCPManagedCluster
- equal:
path: metadata.name
value: plural
- isNullOrEmpty:
path: spec.project
- isNullOrEmpty:
path: spec.region
- lengthEqual:
path: spec.network.subnets
count: 1
- equal:
path: spec.network.subnets[0].name
value: plural-subnetwork
- it: should not be created when provider is not gcp
set:
type: managed
asserts:
- hasDocuments:
count: 0

Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
suite: test gcp control plane
templates:
- gcp/control-plane.yaml
tests:
- it: should be created with default values when provider is gcp
set:
provider: gcp
type: managed
asserts:
- hasDocuments:
count: 1
- isKind:
of: GCPManagedControlPlane
- equal:
path: metadata.name
value: plural
- equal:
path: spec.clusterName
value: plural
- isNullOrEmpty:
path: spec.project
- isNullOrEmpty:
path: spec.location
- equal:
path: spec.controlPlaneVersion
value: "1.24.16"
- it: should use custom kubernetes version if provided
set:
provider: gcp
type: managed
cluster.kubernetesVersion: 1.24
asserts:
- hasDocuments:
count: 1
- isKind:
of: GCPManagedControlPlane
- equal:
path: spec.controlPlaneVersion
value: "1.24"
- it: should not contain release channel if set to "unspecified"
set:
provider: gcp
type: managed
cluster.gcp.releaseChannel: unspecified
asserts:
- hasDocuments:
count: 1
- isKind:
of: GCPManagedControlPlane
- notExists:
path: spec.releaseChannel
- it: should contain release channel if set
set:
provider: gcp
type: managed
cluster.gcp.releaseChannel: stable
asserts:
- hasDocuments:
count: 1
- isKind:
of: GCPManagedControlPlane
- equal:
path: spec.releaseChannel
value: stable
- it: should not be created when provider is not gcp
set:
type: managed
asserts:
- hasDocuments:
count: 0

Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
suite: test gcp machine pools
templates:
- gcp/machinepools.yaml
tests:
- it: should be created with default values when provider is gcp
set:
provider: gcp
type: managed
asserts:
- hasDocuments:
count: 6
- documentIndex: 0
isKind:
of: GCPManagedMachinePool
- documentIndex: 1
isKind:
of: MachinePool
- documentIndex: 0
equal:
path: metadata.name
value: large-burst-on-demand
- documentIndex: 0
equal:
path: spec.nodePoolName
value: large-burst-on-demand
- documentIndex: 0
equal:
path: spec.machineType
value: e2-standard-8
- documentIndex: 2
equal:
path: metadata.name
value: medium-burst-on-demand
- documentIndex: 2
equal:
path: spec.nodePoolName
value: medium-burst-on-demand
- documentIndex: 2
equal:
path: spec.machineType
value: e2-standard-4
- documentIndex: 4
equal:
path: metadata.name
value: small-burst-on-demand
- documentIndex: 4
equal:
path: spec.nodePoolName
value: small-burst-on-demand
- documentIndex: 4
equal:
path: spec.machineType
value: e2-standard-2
- it: should have default kubernetes version set
set:
provider: gcp
type: managed
asserts:
- documentIndex: 1
equal:
path: spec.template.spec.version
value: "1.24.16"
- it: should have custom kubernetes version set
set:
provider: gcp
type: managed
cluster.kubernetesVersion: 1.24
asserts:
- documentIndex: 1
equal:
path: spec.template.spec.version
value: "1.24"
- it: should not be created when provider is not gcp
set:
type: managed
asserts:
- hasDocuments:
count: 0

3 changes: 3 additions & 0 deletions bootstrap/terraform/kind-bootstrap-cluster-api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Kind Kubernetes bootstrapping

Provisions a local kubernetes cluster using KinD
13 changes: 13 additions & 0 deletions bootstrap/terraform/kind-bootstrap-cluster-api/deps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: plural.sh/v1alpha1
kind: Dependencies
metadata:
description: Creates a local Kubernetes cluster using KinD
version: 0.1.0
spec:
dependencies: []
providers:
- kind
outputs:
cluster: cluster
provider_wirings:
cluster: module.kind-bootstrap-cluster-api.cluster
2 changes: 2 additions & 0 deletions bootstrap/terraform/kind-bootstrap-cluster-api/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@


8 changes: 8 additions & 0 deletions bootstrap/terraform/kind-bootstrap-cluster-api/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
output "cluster" {
value = var.cluster_name
sensitive = true
}

output "kubeconfig_path" {
value = "${path.root}/kube_config_cluster.yaml"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cluster_name = {{ .Cluster | quote }}
7 changes: 7 additions & 0 deletions bootstrap/terraform/kind-bootstrap-cluster-api/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
variable "cluster_name" {
type = string
description = "Name of your cluster. Alpha-numeric and hyphens only, please."
default = "kind"
}


9 changes: 9 additions & 0 deletions bootstrap/terraform/kind-bootstrap-cluster-api/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
required_providers {
kind = {
source = "kyma-incubator/kind"
version = ">= 0.0.11, <0.1.0"
}
}
required_version = ">= 0.14"
}