Skip to content

Commit

Permalink
Move Values.metadata to Values.global.metadata (#413)
Browse files Browse the repository at this point in the history
* Move Helm values property .Values.metadata to .Values.global.metadata

* Fix metadata values usage in Cluster resource

* Fix metadata values usage in aws-ebs-csi-driver HelmRelease

* Fix metadata values usage in cilium HelmRelease

* Fix metadata values usage in aws-cloud-controller-manager HelmRelease

* Fix metadata values usage in coredns HelmRelease

* Fix metadata values usage in default HelmRepositories

* Fix metadata values usage in vertical-pod-autoscaler-crd HelmRelease

* Render templates from main branch with test values from main branch

* Correctly render Helm values docs
  • Loading branch information
nprokopic authored Nov 29, 2023
1 parent f0c3096 commit d0b00f1
Show file tree
Hide file tree
Showing 17 changed files with 93 additions and 74 deletions.
27 changes: 24 additions & 3 deletions .github/workflows/zz_generated.diff_helm_render_templates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,32 @@ jobs:
echo "values=[\"$(ls -m helm/${{ github.event.repository.name }}/ci/test-*-values.yaml | tr -d ' \n' | sed 's/,/\", \"/g')\"]" >> $GITHUB_OUTPUT
outputs:
values: ${{ steps.get-rendering-values.outputs.values }}
get-old-rendering-values:
needs: check-cmp-state
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && needs.check-cmp-state.outputs.suspendcmp == 0
steps:
- uses: actions/checkout@v4
with:
ref: "${{ github.event.repository.default_branch }}"
path: 'old'
- name: list old rendering values
id: get-old-rendering-values
run: |
echo "values=[\"$(ls -m old/helm/${{ github.event.repository.name }}/ci/test-*-values.yaml | tr -d ' \n' | sed 's/,/\", \"/g')\"]"
echo
echo "values=[\"$(ls -m old/helm/${{ github.event.repository.name }}/ci/test-*-values.yaml | tr -d ' \n' | sed 's/,/\", \"/g')\"]" >> $GITHUB_OUTPUT
outputs:
values: ${{ steps.get-old-rendering-values.outputs.values }}
cmp-helm-rendering:
needs: get-rendering-values
needs:
- get-rendering-values
- get-old-rendering-values
runs-on: ubuntu-latest
strategy:
matrix:
values: ${{ fromJson(needs.get-rendering-values.outputs.values) }}
oldValues: ${{ fromJson(needs.get-old-rendering-values.outputs.values) }}
if: github.event_name == 'pull_request'
steps:
- name: install helm
Expand Down Expand Up @@ -90,15 +110,16 @@ jobs:
path: 'old'
- name: render helm with main branch code
run: |
mkdir -p /tmp/${{ matrix.oldValues }}
# TODO split files by "API"_"KIND"_"NAMESPACE|clusterwide"_"NAME"
helm dependency build old/helm/${{ github.event.repository.name }}
helm template -n org-giantswarm -f "old/helm/${{ github.event.repository.name }}/ci/ci-values.yaml" -f "${{ matrix.values }}" "old/helm/${{ github.event.repository.name }}" > /tmp/${{ matrix.values }}/render-old.yaml
helm template -n org-giantswarm -f "old/helm/${{ github.event.repository.name }}/ci/ci-values.yaml" -f "${{ matrix.oldValues }}" "old/helm/${{ github.event.repository.name }}" > /tmp/${{ matrix.oldValues }}/render-old.yaml
- name: get the diffs
uses: mathiasvr/command-output@v1
id: diff
with:
run: |
dyff between -s -i -b -g /tmp/${{ matrix.values }}/render-old.yaml /tmp/${{ matrix.values }}/render-new.yaml && echo "No diff detected" || if [[ $? -eq 255 ]]; then echo "Diff error"; fi;
dyff between -s -i -b -g /tmp/${{ matrix.oldValues }}/render-old.yaml /tmp/${{ matrix.values }}/render-new.yaml && echo "No diff detected" || if [[ $? -eq 255 ]]; then echo "Diff error"; fi;
- name: Find diff comment
uses: peter-evans/find-comment@v2
continue-on-error: true
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### **Breaking change**

- Move Helm values property `.Values.metadata` to `.Values.global.metadata`.

### Added

- Expose value to configure launch template overrides, used to override the instance type specified by the launch template with multiple instance types that can be used to launch instances.
Expand Down
14 changes: 4 additions & 10 deletions helm/cluster-aws/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,11 @@ Properties within the `.global.metadata` object

| **Property** | **Description** | **More Details** |
| :----------- | :-------------- | :--------------- |
| `global.metadata.description` | **Cluster description** - User-friendly description of the cluster's purpose.|**Type:** `string`<br/>|
| `global.metadata.name` | **Cluster name** - Unique identifier, cannot be changed after creation.|**Type:** `string`<br/>|
| `global.metadata.organization` | **Organization**|**Type:** `string`<br/>|
| `global.metadata.preventDeletion` | **Prevent cluster deletion**|**Type:** `boolean`<br/>**Default:** `false`|

### Metadata
Properties within the `.metadata` top-level object

| **Property** | **Description** | **More Details** |
| :----------- | :-------------- | :--------------- |
| `metadata.description` | **Cluster description** - User-friendly description of the cluster's purpose.|**Type:** `string`<br/>|
| `metadata.name` | **Cluster name** - Unique identifier, cannot be changed after creation.|**Type:** `string`<br/>|
| `metadata.organization` | **Organization**|**Type:** `string`<br/>|
| `metadata.servicePriority` | **Service priority** - The relative importance of this cluster.|**Type:** `string`<br/>**Default:** `"highest"`|
| `global.metadata.servicePriority` | **Service priority** - The relative importance of this cluster.|**Type:** `string`<br/>**Default:** `"highest"`|

### Node pools
Properties within the `.nodePools` top-level object
Expand Down
5 changes: 3 additions & 2 deletions helm/cluster-aws/ci/ci-values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
metadata:
organization: "test"
global:
metadata:
organization: "test"
baseDomain: example.com

connectivity:
Expand Down
9 changes: 5 additions & 4 deletions helm/cluster-aws/ci/test-mc-proxy.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
metadata:
name: test-mc-proxy
organization: test
servicePriority: lowest
global:
metadata:
name: test-mc-proxy
organization: test
servicePriority: lowest
baseDomain: example.com
connectivity:
proxy:
Expand Down
9 changes: 5 additions & 4 deletions helm/cluster-aws/ci/test-spot-instances.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
metadata:
name: test-wc-minimal
organization: test
servicePriority: lowest
global:
metadata:
name: test-wc-minimal
organization: test
servicePriority: lowest
baseDomain: example.com
nodePools:
pool0:
Expand Down
9 changes: 5 additions & 4 deletions helm/cluster-aws/ci/test-wc-minimal-values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
metadata:
name: test-wc-minimal
organization: test
servicePriority: lowest
global:
metadata:
name: test-wc-minimal
organization: test
servicePriority: lowest
baseDomain: example.com
6 changes: 3 additions & 3 deletions helm/cluster-aws/templates/_cluster.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
annotations:
{{- with .Values.metadata.description }}
{{- with .Values.global.metadata.description }}
cluster.giantswarm.io/description: "{{ . }}"
{{- end }}
network-topology.giantswarm.io/mode: "{{ .Values.connectivity.topology.mode }}"
Expand All @@ -15,8 +15,8 @@ metadata:
{{- end }}
labels:
cluster-apps-operator.giantswarm.io/watching: ""
{{- if .Values.metadata.servicePriority }}
giantswarm.io/service-priority: {{ .Values.metadata.servicePriority }}
{{- if .Values.global.metadata.servicePriority }}
giantswarm.io/service-priority: {{ .Values.global.metadata.servicePriority }}
{{- end }}
{{- include "labels.common" $ | nindent 4 }}
{{- include "preventDeletionLabel" $ | nindent 4 -}}
Expand Down
4 changes: 2 additions & 2 deletions helm/cluster-aws/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ app: {{ include "name" . | quote }}
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
cluster.x-k8s.io/cluster-name: {{ include "resource.default.name" . | quote }}
giantswarm.io/cluster: {{ include "resource.default.name" . | quote }}
giantswarm.io/organization: {{ required "You must provide an existing organization name in .metadata.organization" .Values.metadata.organization | quote }}
giantswarm.io/organization: {{ required "You must provide an existing organization name in .global.metadata.organization" .Values.global.metadata.organization | quote }}
cluster.x-k8s.io/watch-filter: capi
{{- end -}}

Expand All @@ -42,7 +42,7 @@ Given that Kubernetes allows 63 characters for resource names, the stem is trunc
room for such suffix.
*/}}
{{- define "resource.default.name" -}}
{{- .Values.metadata.name | default (.Release.Name | replace "." "-" | trunc 47 | trimSuffix "-") -}}
{{- .Values.global.metadata.name | default (.Release.Name | replace "." "-" | trunc 47 | trimSuffix "-") -}}
{{- end -}}

{{- define "controlPlaneFiles" -}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: {{ include "resource.default.name" $ }}-aws-ebs-csi-driver
namespace: {{ $.Release.Namespace }}
annotations:
cluster.giantswarm.io/description: "{{ .Values.metadata.description }}"
cluster.giantswarm.io/description: "{{ .Values.global.metadata.description }}"
labels:
cluster-apps-operator.giantswarm.io/watching: ""
{{- include "labels.common" . | nindent 4 }}
Expand Down
2 changes: 1 addition & 1 deletion helm/cluster-aws/templates/cilium-helmrelease.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: {{ include "resource.default.name" $ }}-cilium
namespace: {{ $.Release.Namespace }}
annotations:
cluster.giantswarm.io/description: "{{ .Values.metadata.description }}"
cluster.giantswarm.io/description: "{{ .Values.global.metadata.description }}"
labels:
{{- include "labels.common" . | nindent 4 }}
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: {{ include "resource.default.name" $ }}-cloud-provider-aws
namespace: {{ $.Release.Namespace }}
annotations:
cluster.giantswarm.io/description: "{{ .Values.metadata.description }}"
cluster.giantswarm.io/description: "{{ .Values.global.metadata.description }}"
labels:
cluster-apps-operator.giantswarm.io/watching: ""
{{- include "labels.common" . | nindent 4 }}
Expand Down
2 changes: 1 addition & 1 deletion helm/cluster-aws/templates/coredns-helmrelease.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: {{ include "resource.default.name" $ }}-coredns
namespace: {{ $.Release.Namespace }}
annotations:
cluster.giantswarm.io/description: "{{ .Values.metadata.description }}"
cluster.giantswarm.io/description: "{{ .Values.global.metadata.description }}"
labels:
{{- include "labels.common" . | nindent 4 }}
spec:
Expand Down
4 changes: 2 additions & 2 deletions helm/cluster-aws/templates/default-helmrepository.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: {{ include "resource.default.name" $ }}-default
namespace: {{ $.Release.Namespace }}
annotations:
cluster.giantswarm.io/description: "{{ .Values.metadata.description }}"
cluster.giantswarm.io/description: "{{ .Values.global.metadata.description }}"
labels:
{{- include "labels.common" . | nindent 4 }}
spec:
Expand All @@ -17,7 +17,7 @@ metadata:
name: {{ include "resource.default.name" $ }}-default-test
namespace: {{ $.Release.Namespace }}
annotations:
cluster.giantswarm.io/description: "{{ .Values.metadata.description }}"
cluster.giantswarm.io/description: "{{ .Values.global.metadata.description }}"
labels:
{{- include "labels.common" . | nindent 4 }}
spec:
Expand Down
2 changes: 1 addition & 1 deletion helm/cluster-aws/templates/vpa-crd-helmrelease.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: {{ include "resource.default.name" $ }}-vertical-pod-autoscaler-crd
namespace: {{ $.Release.Namespace }}
annotations:
cluster.giantswarm.io/description: "{{ .Values.metadata.description }}"
cluster.giantswarm.io/description: "{{ .Values.global.metadata.description }}"
labels:
{{- include "labels.common" . | nindent 4 }}
spec:
Expand Down
63 changes: 30 additions & 33 deletions helm/cluster-aws/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,19 +700,48 @@
},
"global": {
"type": "object",
"title": "Global properties",
"title": "Global",
"description": "Properties that are available to all charts and subcharts.",
"required": [
"metadata"
],
"additionalProperties": true,
"properties": {
"metadata": {
"type": "object",
"title": "Metadata",
"additionalProperties": true,
"properties": {
"description": {
"type": "string",
"title": "Cluster description",
"description": "User-friendly description of the cluster's purpose."
},
"name": {
"type": "string",
"title": "Cluster name",
"description": "Unique identifier, cannot be changed after creation."
},
"organization": {
"type": "string",
"title": "Organization"
},
"preventDeletion": {
"type": "boolean",
"title": "Prevent cluster deletion",
"default": false
},
"servicePriority": {
"type": "string",
"title": "Service priority",
"description": "The relative importance of this cluster.",
"$comment": "Defined in https://github.com/giantswarm/rfc/tree/main/classify-cluster-priority",
"enum": [
"highest",
"medium",
"lowest"
],
"default": "highest"
}
}
}
Expand Down Expand Up @@ -912,38 +941,6 @@
"title": "Management cluster",
"description": "Name of the Cluster API cluster managing this workload cluster."
},
"metadata": {
"type": "object",
"title": "Metadata",
"properties": {
"description": {
"type": "string",
"title": "Cluster description",
"description": "User-friendly description of the cluster's purpose."
},
"name": {
"type": "string",
"title": "Cluster name",
"description": "Unique identifier, cannot be changed after creation."
},
"organization": {
"type": "string",
"title": "Organization"
},
"servicePriority": {
"type": "string",
"title": "Service priority",
"description": "The relative importance of this cluster.",
"$comment": "Defined in https://github.com/giantswarm/rfc/tree/main/classify-cluster-priority",
"enum": [
"highest",
"medium",
"lowest"
],
"default": "highest"
}
}
},
"nodePools": {
"type": "object",
"title": "Node pools",
Expand Down
3 changes: 1 addition & 2 deletions helm/cluster-aws/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ controlPlane:
global:
metadata:
preventDeletion: false
servicePriority: highest
internal:
cgroupsv1: false
kubernetesVersion: 1.24.14
Expand All @@ -83,8 +84,6 @@ kubectlImage:
name: giantswarm/kubectl
registry: quay.io
tag: 1.23.5
metadata:
servicePriority: highest
providerSpecific:
awsClusterRoleIdentityName: default
flatcarAwsAccount: "706635527432"

0 comments on commit d0b00f1

Please sign in to comment.