From 1ee638406ef002b15577fdb4ea520383a3578ee4 Mon Sep 17 00:00:00 2001 From: Antonia <56017655+anvddriesch@users.noreply.github.com> Date: Thu, 29 Aug 2024 21:32:03 +0900 Subject: [PATCH] allow setting additional annotations on the vsphere cluster object (#279) * allow setting additional annotations on the vsphere cluster object * typo * sort * sort changelog * make the name clearer * remove default annotation --- CHANGELOG.md | 2 ++ helm/cluster-vsphere/README.md | 4 +++- .../templates/_additional_annotations.tpl | 7 +++++++ .../templates/vspherecluster.yaml | 3 +++ helm/cluster-vsphere/values.schema.json | 19 +++++++++++++++++++ helm/cluster-vsphere/values.yaml | 1 + 6 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 helm/cluster-vsphere/templates/_additional_annotations.tpl diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b2df067..baf3b746 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- Allow adding custom annotations to the infrastructure cluster resource using `providerSpecific.additionalVsphereClusterAnnotations` value. + ## [0.61.0] - 2024-08-23 > [!WARNING] diff --git a/helm/cluster-vsphere/README.md b/helm/cluster-vsphere/README.md index 6b779303..7a258b69 100644 --- a/helm/cluster-vsphere/README.md +++ b/helm/cluster-vsphere/README.md @@ -145,6 +145,8 @@ Properties within the `.global.providerSpecific` object | **Property** | **Description** | **More Details** | | :----------- | :-------------- | :--------------- | +| `global.providerSpecific.additionalVsphereClusterAnnotations` | **Additional vsphere cluster annotations** - Additional annotations to be added to the vspherecluster custom resource.|**Type:** `object`
**Default:** `{}`| +| `global.providerSpecific.additionalVsphereClusterAnnotations.*` | **Annotation value** - Value of the annotation|**Type:** `string`
| | `global.providerSpecific.defaultStorageClass` | **Default Storage Class** - Configuration of the default storage class.|**Type:** `object`
| | `global.providerSpecific.defaultStorageClass.enabled` | **Enable default storage class** - Creates a default storage class if set to true.|**Type:** `boolean`
**Default:** `true`| | `global.providerSpecific.defaultStorageClass.reclaimPolicy` | **Reclaim Policy** - Reclaim policy of the storage class (Delete or Retain).|**Type:** `string`
**Default:** `"Delete"`| @@ -171,4 +173,4 @@ Properties within the `.global.providerSpecific` object - \ No newline at end of file + diff --git a/helm/cluster-vsphere/templates/_additional_annotations.tpl b/helm/cluster-vsphere/templates/_additional_annotations.tpl new file mode 100644 index 00000000..35ae1289 --- /dev/null +++ b/helm/cluster-vsphere/templates/_additional_annotations.tpl @@ -0,0 +1,7 @@ +{{- define "additional-annotations" -}} +{{- $tags := .Values.global.providerSpecific.additionalVsphereClusterAnnotations | default dict }} +annotations: + {{- if $tags }} + {{- toYaml $tags | nindent 2 }} + {{- end -}} +{{- end -}} diff --git a/helm/cluster-vsphere/templates/vspherecluster.yaml b/helm/cluster-vsphere/templates/vspherecluster.yaml index db87be12..b2a8d9d1 100644 --- a/helm/cluster-vsphere/templates/vspherecluster.yaml +++ b/helm/cluster-vsphere/templates/vspherecluster.yaml @@ -1,6 +1,9 @@ apiVersion: {{ include "infrastructureApiVersion" . }} kind: VSphereCluster metadata: + {{- if .Values.global.providerSpecific.additionalVsphereClusterAnnotations -}} + {{- include "additional-annotations" . | indent 2}} + {{- end }} name: {{ include "resource.default.name" $ }} namespace: {{ .Release.Namespace }} labels: diff --git a/helm/cluster-vsphere/values.schema.json b/helm/cluster-vsphere/values.schema.json index ecab3969..35ceb9c2 100644 --- a/helm/cluster-vsphere/values.schema.json +++ b/helm/cluster-vsphere/values.schema.json @@ -856,6 +856,25 @@ "type": "object", "title": "Provider specific configuration", "properties": { + "additionalVsphereClusterAnnotations": { + "type": "object", + "title": "Additional vsphere cluster annotations", + "description": "Additional annotations to be added to the vspherecluster custom resource.", + "additionalProperties": { + "type": "string", + "title": "Annotation value", + "description": "Value of the annotation", + "maxLength": 256 + }, + "default": {}, + "propertyNames": { + "type": "string", + "title": "Annotation name", + "description": "Name of the annotation", + "maxLength": 128, + "pattern": "^[^<>%&?/\\\\]*$" + } + }, "defaultStorageClass": { "type": "object", "title": "Default Storage Class", diff --git a/helm/cluster-vsphere/values.yaml b/helm/cluster-vsphere/values.yaml index 04095e59..9137b1ec 100644 --- a/helm/cluster-vsphere/values.yaml +++ b/helm/cluster-vsphere/values.yaml @@ -230,6 +230,7 @@ global: podSecurityStandards: enforced: true providerSpecific: + additionalVsphereClusterAnnotations: {} defaultStorageClass: enabled: true reclaimPolicy: Delete