Skip to content

Commit

Permalink
Initial integration of shared cluster chart (#238)
Browse files Browse the repository at this point in the history
* fall back to default nodepool if none are defined

* improve variable names to be more explanatory

* add shared charts as dependencies

* add cluster name to all CI value files

* update changelog

* update values schema and yaml

* update chart readme

* make nodePools optional to ensure cluster chart defaults are used

* add trailing newline to appease our Linting Overlords

* delete redundant cluster manifest

* improve changelog
  • Loading branch information
glitchcrab authored Jul 22, 2024
1 parent d73fab8 commit 048464f
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 51 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

### **Breaking change**.

> [!CAUTION]
> The cluster name must be added to the cluster values when upgrading to this chart release.
<details>
<summary>How to migrate values (from v0.56.1)</summary>

The cluster's name must be added to the cluster values in order to satisfy the updated values
schema. This can be done by adding the existing cluster name to the `cluster` values. For example,
where the cluster is named `test`:

```yaml
global:
metadata:
name: test
```
</details>
- Initial integration of shared `cluster` chart to render `Cluster` resource.

## [0.56.1] - 2024-07-16

### Added
Expand Down
9 changes: 9 additions & 0 deletions helm/cluster-vsphere/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencies:
- name: cluster
repository: https://giantswarm.github.io/cluster-catalog
version: 0.35.0
- name: cluster-shared
repository: https://giantswarm.github.io/cluster-catalog
version: 0.7.1
digest: sha256:dd593d4433f91fa04497f8afbdbd2ac33b5a7c6be2efacfc9a71f7f613131853
generated: "2024-07-17T13:29:07.563718968+01:00"
7 changes: 7 additions & 0 deletions helm/cluster-vsphere/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,10 @@ maintainers:
restrictions:
compatibleProviders:
- vsphere
dependencies:
- name: cluster
version: "0.35.0"
repository: "https://giantswarm.github.io/cluster-catalog"
- name: cluster-shared
version: "0.7.1"
repository: "https://giantswarm.github.io/cluster-catalog"
3 changes: 3 additions & 0 deletions helm/cluster-vsphere/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ Properties within the `.global.metadata` object
| `global.metadata.description` | **Cluster description** - User-friendly description of the cluster's purpose.|**Type:** `string`<br/>|
| `global.metadata.labels` | **Labels** - These labels are added to the Kubernetes resources defining this cluster.|**Type:** `object`<br/>|
| `global.metadata.labels.PATTERN` | **Label**|**Type:** `string`<br/>**Key pattern:**<br/>`PATTERN`=`^[a-zA-Z0-9/\._-]+$`<br/>**Value pattern:** `^[a-zA-Z0-9\._-]+$`<br/>|
| `global.metadata.name` | **Cluster name**|**Type:** `string`<br/>|
| `global.metadata.organization` | **Organization**|**Type:** `string`<br/>|
| `global.metadata.preventDeletion` | **Prevent cluster deletion**|**Type:** `boolean`<br/>**Default:** `false`|
| `global.metadata.servicePriority` | **Service priority** - The relative importance of this cluster.|**Type:** `string`<br/>**Default:** `"highest"`|
Expand Down Expand Up @@ -177,6 +178,8 @@ Properties within the `.global.providerSpecific` object
| **Property** | **Description** | **More Details** |
| :----------- | :-------------- | :--------------- |
| `baseDomain` | **Base DNS domain**|**Type:** `string`<br/>|
| `cluster` | **Cluster** - Helm values for the provider-independent cluster chart.|**Type:** `object`<br/>**Default:** `{"providerIntegration":{"controlPlane":{"resources":{"infrastructureMachineTemplate":{"group":"infrastructure.cluster.x-k8s.io","kind":"VSphereMachineTemplate","version":"v1beta1"},"infrastructureMachineTemplateSpecTemplateName":"controlplane-vspheremachinetemplate-spec"}},"provider":"vsphere","resourcesApi":{"bastionResourceEnabled":false,"ciliumHelmReleaseResourceEnabled":false,"cleanupHelmReleaseResourcesEnabled":false,"clusterResourceEnabled":true,"controlPlaneResourceEnabled":false,"coreDnsHelmReleaseResourceEnabled":false,"helmRepositoryResourcesEnabled":false,"infrastructureCluster":{"group":"infrastructure.cluster.x-k8s.io","kind":"VSphereCluster","version":"v1beta1"},"machineHealthCheckResourceEnabled":false,"machinePoolResourcesEnabled":false,"networkPoliciesHelmReleaseResourceEnabled":false,"nodePoolKind":"MachineDeployment","verticalPodAutoscalerCrdHelmReleaseResourceEnabled":false},"workers":{"defaultNodePools":{"def00":{"cloneMode":"linkedClone","memoryMiB":16896,"network":{},"numCPUs":6,"replicas":2,"resourcePool":"*/Resources","template":"flatcar-stable-3815.2.2-kube-v1.27.14-gs"}}}}}`|
| `cluster-shared` | **Library chart**|**Type:** `object`<br/>|
| `managementCluster` | **Management cluster name**|**Type:** `string`<br/>|
| `provider` | **Provider name**|**Type:** `string`<br/>|

Expand Down
1 change: 1 addition & 0 deletions helm/cluster-vsphere/ci/ci-values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
global:
metadata:
description: "test cluster"
name: "test cluster"
organization: "giantswarm"
connectivity:
network:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
global:
metadata:
description: "test cluster"
name: "test cluster"
organization: "giantswarm"
connectivity:
containerRegistries:
Expand Down
1 change: 1 addition & 0 deletions helm/cluster-vsphere/ci/test-wc-values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
global:
metadata:
description: "test cluster"
name: "test cluster"
organization: "giantswarm"
connectivity:
network:
Expand Down
4 changes: 2 additions & 2 deletions helm/cluster-vsphere/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ create VSphereMachineTemplates.
{{ define "createMapOfClusterNodeSpecs" }}
{{- $nodeMap := dict -}}
{{- $_ := set $nodeMap "control-plane" .Values.global.controlPlane.machineTemplate -}}
{{- range $index, $pool := .Values.global.nodePools -}}
{{- range $index, $pool := .Values.global.nodePools | default .Values.cluster.providerIntegration.workers.defaultNodePools -}}
{{- $_ := set $nodeMap $index $pool -}}
{{- end -}}
{{ toYaml $nodeMap }}
Expand All @@ -65,7 +65,7 @@ MachineDeployments.
*/}}
{{ define "createMapOfWorkerPoolSpecs" -}}
{{- $nodeMap := dict -}}
{{- range $index, $pool := .Values.global.nodePools -}}
{{- range $index, $pool := .Values.global.nodePools | default .Values.cluster.providerIntegration.workers.defaultNodePools -}}
{{- $_ := set $nodeMap $index $pool -}}
{{- end -}}
{{ toYaml $nodeMap }}
Expand Down
41 changes: 0 additions & 41 deletions helm/cluster-vsphere/templates/cluster.yaml

This file was deleted.

8 changes: 4 additions & 4 deletions helm/cluster-vsphere/templates/machinedeployment.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- range $name, $value := include "createMapOfWorkerPoolSpecs" . | fromYaml }}
{{- range $nodePoolName, $value := include "createMapOfWorkerPoolSpecs" . | fromYaml }}
{{- $c := (merge (dict "currentPool" $value) $.Values) }}
{{/* we deepcopy the $value variable inside the loop because it is mutated when it is passed to
kubeadmConfigTemplateRevision which then affects later functions which also rely on $values.
Expand All @@ -8,7 +8,7 @@ $valuesDeepCopied should only be used with the call to kubeadmConfigTemplateRevi
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
name: {{ include "resource.default.name" $ }}-{{ $name }}
name: {{ include "resource.default.name" $ }}-{{ $nodePoolName }}
namespace: {{ $.Release.Namespace }}
labels:
{{- include "labels.common" $ | nindent 4 }}
Expand All @@ -28,13 +28,13 @@ spec:
configRef:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
name: {{ include "resource.default.name" $ }}-{{ $name }}-{{ include "kubeadmConfigTemplateRevision" (merge (dict "pool" (set $valueDeepCopied "name" $name)) $) }}
name: {{ include "resource.default.name" $ }}-{{ $nodePoolName }}-{{ include "kubeadmConfigTemplateRevision" (merge (dict "pool" (set $valueDeepCopied "name" $nodePoolName)) $) }}
namespace: {{ $.Release.Namespace }}
clusterName: {{ include "resource.default.name" $ }}
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: VSphereMachineTemplate
name: {{ include "resource.default.name" $ }}-{{ $name }}-{{ include "mtRevision" $c }}
name: {{ include "resource.default.name" $ }}-{{ $nodePoolName }}-{{ include "mtRevision" $c }}
namespace: {{ $.Release.Namespace }}
version: {{ $.Values.internal.kubernetesVersion }}
{{- end }}
4 changes: 2 additions & 2 deletions helm/cluster-vsphere/templates/vspheremachinetemplate.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{{- range $name, $value := include "createMapOfClusterNodeSpecs" . | fromYaml }}
{{- range $nodePoolName, $value := include "createMapOfClusterNodeSpecs" . | fromYaml }}
{{- $c := (merge (dict "currentPool" $value) (deepCopy $.Values)) }}
---
apiVersion: {{ include "infrastructureApiVersion" . }}
kind: VSphereMachineTemplate
metadata:
name: {{ include "resource.default.name" $ }}-{{ $name }}-{{ include "mtRevision" $c }}
name: {{ include "resource.default.name" $ }}-{{ $nodePoolName }}-{{ include "mtRevision" $c }}
namespace: {{ $.Release.Namespace }}
labels:
{{- include "labels.common" $ | nindent 4 }}
Expand Down
63 changes: 61 additions & 2 deletions helm/cluster-vsphere/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,67 @@
"type": "string",
"title": "Base DNS domain"
},
"cluster": {
"type": "object",
"title": "Cluster",
"description": "Helm values for the provider-independent cluster chart.",
"default": {
"providerIntegration": {
"controlPlane": {
"resources": {
"infrastructureMachineTemplate": {
"group": "infrastructure.cluster.x-k8s.io",
"kind": "VSphereMachineTemplate",
"version": "v1beta1"
},
"infrastructureMachineTemplateSpecTemplateName": "controlplane-vspheremachinetemplate-spec"
}
},
"provider": "vsphere",
"resourcesApi": {
"bastionResourceEnabled": false,
"ciliumHelmReleaseResourceEnabled": false,
"cleanupHelmReleaseResourcesEnabled": false,
"clusterResourceEnabled": true,
"controlPlaneResourceEnabled": false,
"coreDnsHelmReleaseResourceEnabled": false,
"helmRepositoryResourcesEnabled": false,
"infrastructureCluster": {
"group": "infrastructure.cluster.x-k8s.io",
"kind": "VSphereCluster",
"version": "v1beta1"
},
"machineHealthCheckResourceEnabled": false,
"machinePoolResourcesEnabled": false,
"networkPoliciesHelmReleaseResourceEnabled": false,
"nodePoolKind": "MachineDeployment",
"verticalPodAutoscalerCrdHelmReleaseResourceEnabled": false
},
"workers": {
"defaultNodePools": {
"def00": {
"cloneMode": "linkedClone",
"memoryMiB": 16896,
"network": {},
"numCPUs": 6,
"replicas": 2,
"resourcePool": "*/Resources",
"template": "flatcar-stable-3815.2.2-kube-v1.27.14-gs"
}
}
}
}
}
},
"cluster-shared": {
"type": "object",
"title": "Library chart"
},
"global": {
"type": "object",
"title": "Properties that are available to all charts and subcharts",
"required": [
"metadata",
"nodePools"
"metadata"
],
"properties": {
"connectivity": {
Expand Down Expand Up @@ -518,6 +573,10 @@
}
}
},
"name": {
"type": "string",
"title": "Cluster name"
},
"organization": {
"type": "string",
"title": "Organization"
Expand Down
37 changes: 37 additions & 0 deletions helm/cluster-vsphere/values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,42 @@
# Auto-generated by helm-values-gen, do not edit!

cluster:
providerIntegration:
controlPlane:
resources:
infrastructureMachineTemplate:
group: infrastructure.cluster.x-k8s.io
kind: VSphereMachineTemplate
version: v1beta1
infrastructureMachineTemplateSpecTemplateName: controlplane-vspheremachinetemplate-spec
provider: vsphere
resourcesApi:
bastionResourceEnabled: false
ciliumHelmReleaseResourceEnabled: false
cleanupHelmReleaseResourcesEnabled: false
clusterResourceEnabled: true
controlPlaneResourceEnabled: false
coreDnsHelmReleaseResourceEnabled: false
helmRepositoryResourcesEnabled: false
infrastructureCluster:
group: infrastructure.cluster.x-k8s.io
kind: VSphereCluster
version: v1beta1
machineHealthCheckResourceEnabled: false
machinePoolResourcesEnabled: false
networkPoliciesHelmReleaseResourceEnabled: false
nodePoolKind: MachineDeployment
verticalPodAutoscalerCrdHelmReleaseResourceEnabled: false
workers:
defaultNodePools:
def00:
cloneMode: linkedClone
memoryMiB: 16896
network: {}
numCPUs: 6
replicas: 2
resourcePool: '*/Resources'
template: flatcar-stable-3815.2.2-kube-v1.27.14-gs
global:
connectivity:
containerRegistries: {}
Expand Down

0 comments on commit 048464f

Please sign in to comment.