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

fix: move kubernetes version to template and add gcp unit tests #844

Merged
merged 4 commits into from
Sep 13, 2023
Merged
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
2 changes: 1 addition & 1 deletion bootstrap/helm/cluster-api-cluster/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: cluster-api-cluster
description: A Helm chart for Kubernetes
type: application
version: 0.1.42
version: 0.1.43
appVersion: v1.24.16
6 changes: 0 additions & 6 deletions bootstrap/helm/cluster-api-cluster/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@ Creates the Kubernetes version for the cluster
{{- define "cluster.kubernetesVersion" -}}
{{- if .Values.cluster.kubernetesVersion -}}
{{ .Values.cluster.kubernetesVersion }}
{{- else if eq .Values.provider "aws" -}}
v1.24
{{- else if eq .Values.provider "azure" -}}
v1.25.11
{{- else if and (eq .Values.provider "gcp") (eq .Values.type "managed") -}}
1.24.16
{{- else if eq .Values.provider "kind" -}}
v1.25.11
{{- end }}
Expand Down
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,68 @@
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
- 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,70 @@
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 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

6 changes: 0 additions & 6 deletions bootstrap/helm/cluster-api-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,6 @@ workers:
#################################
azure:
lsod:
kubernetesVersion: v1.25.11
spec:
additionalTags: # TODO: allow this to not be set
ScalingGroup: large-sustained-on-demand
Expand All @@ -520,7 +519,6 @@ workers:
lsspot:
replicas: 0
isMultiAZ: true
kubernetesVersion: v1.25.11
spec:
additionalTags: # TODO: allow this to not be set
ScalingGroup: large-sustained-spot
Expand Down Expand Up @@ -549,7 +547,6 @@ workers:
key: kubernetes.azure.com/scalesetpriority
value: spot
msod:
kubernetesVersion: v1.25.11
spec:
additionalTags: # TODO: allow this to not be set
ScalingGroup: medium-sustained-on-demand
Expand All @@ -569,7 +566,6 @@ workers:
sku: Standard_D4as_v5
msspot:
isMultiAZ: true
kubernetesVersion: v1.25.11
spec:
additionalTags: # TODO: allow this to not be set
ScalingGroup: medium-sustained-spot
Expand Down Expand Up @@ -599,7 +595,6 @@ workers:
value: spot
ssod:
replicas: 1
kubernetesVersion: v1.25.11
spec:
additionalTags: # TODO: allow this to not be set
ScalingGroup: small-sustained-on-demand
Expand All @@ -619,7 +614,6 @@ workers:
sku: Standard_D2as_v5
ssspot:
isMultiAZ: true
kubernetesVersion: v1.25.11
spec:
additionalTags: # TODO: allow this to not be set
ScalingGroup: small-sustained-spot
Expand Down
3 changes: 3 additions & 0 deletions bootstrap/helm/cluster-api-cluster/values.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ cluster:
name: {{ .Cluster }}

{{- if eq .Provider "aws" }}
kubernetesVersion: v1.24
aws:
region: {{ .Region }}
iamAuthenticatorConfig:
Expand All @@ -25,6 +26,7 @@ cluster:
{{- end }}

{{- if eq .Provider "azure" }}
kubernetesVersion: v1.25.11
azure:
clusterIdentity:
workloadIdentity:
Expand All @@ -38,6 +40,7 @@ cluster:
{{- end }}

{{- if $isGcp }}
kubernetesVersion: 1.24.17
gcp:
project: {{ .Project }}
region: {{ .Region }}
Expand Down