Skip to content

Commit

Permalink
refactor: move metadata under global key (#296) (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
glitchcrab authored Jun 7, 2024
1 parent e28a497 commit 662c24e
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 78 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ Using `yq`, migrate to the new values layout with the following command:
#!/bin/bash
yq eval --inplace 'with(select(.connectivity != null); .global.connectivity = .connectivity) |
with(select(.baseDomain != null); .global.connectivity.baseDomain = .baseDomain) |
with(select(.metadata != null); .global.metadata = .metadata) |
del(.connectivity) |
del(.baseDomain)' values.yaml
del(.baseDomain) |
del(.metadata)' values.yaml
```

</details>
Expand All @@ -33,6 +35,7 @@ yq eval --inplace 'with(select(.connectivity != null); .global.connectivity = .

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

## [0.52.1] - 2024-05-16

Expand Down
14 changes: 7 additions & 7 deletions helm/cluster-cloud-director/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,16 @@ Used by cluster-shared library chart to configure coredns in-cluster.
| `kubectlImage.tag` | **Tag**|**Type:** `string`<br/>**Default:** `"1.25.15"`|

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

| **Property** | **Description** | **More Details** |
| :----------- | :-------------- | :--------------- |
| `metadata.description` | **Cluster description** - User-friendly description of the cluster's purpose.|**Type:** `string`<br/>|
| `metadata.labels` | **Labels** - These labels are added to the Kubernetes resources defining this cluster.|**Type:** `object`<br/>|
| `metadata.labels.PATTERN` | **Label**|**Type:** `string`<br/>**Key pattern:**<br/>`PATTERN`=`^[a-zA-Z0-9/\._-]+$`<br/>**Value pattern:** `^[a-zA-Z0-9\._-]+$`<br/>|
| `metadata.organization` | **Organization**|**Type:** `string`<br/>|
| `metadata.preventDeletion` | **Prevent cluster deletion**|**Type:** `boolean`<br/>**Default:** `false`|
| `metadata.servicePriority` | **Service priority** - The relative importance of this cluster.|**Type:** `string`<br/>**Default:** `"highest"`|
| `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.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"`|

### Node pools
Properties within the `.nodePools` top-level object
Expand Down
8 changes: 4 additions & 4 deletions helm/cluster-cloud-director/ci/test-wc-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ providerSpecific:
userContext:
secretRef:
secretName: vcd-credentials
metadata:
description: "Testing Cluster"
organization: giantswarm
servicePriority: highest
internal:
kubernetesVersion: v1.25.13+vmware.1
global:
Expand All @@ -42,3 +38,7 @@ global:
loadBalancers:
vipSubnet: 10.205.9.254/24
baseDomain: "test.gigantic.io"
metadata:
description: "Testing Cluster"
organization: giantswarm
servicePriority: highest
6 changes: 3 additions & 3 deletions helm/cluster-cloud-director/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ 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 }}
{{- if .Values.metadata.organization }}
giantswarm.io/organization: {{ .Values.metadata.organization | quote }}
{{- if .Values.global.metadata.organization }}
giantswarm.io/organization: {{ .Values.global.metadata.organization | quote }}
{{- end }}
application.giantswarm.io/team: {{ index .Chart.Annotations "application.giantswarm.io/team" | quote }}
{{- end -}}
Expand All @@ -48,7 +48,7 @@ helm.sh/chart: {{ include "chart" . | quote }}
Create label to prevent accidental cluster deletion
*/}}
{{- define "preventDeletionLabel" -}}
{{- if $.Values.metadata.preventDeletion -}}
{{- if $.Values.global.metadata.preventDeletion -}}
giantswarm.io/prevent-deletion: "true"
{{ end -}}
{{- end -}}
Expand Down
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 | quote }}
cluster.giantswarm.io/description: {{ .Values.global.metadata.description | quote }}
labels:
{{- include "labels.common" . | nindent 4 }}
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ metadata:
name: {{ include "resource.default.name" $ }}-cloud-provider-cloud-director
namespace: {{ $.Release.Namespace }}
annotations:
cluster.giantswarm.io/description: {{ .Values.metadata.description | quote }}
cluster.giantswarm.io/description: {{ .Values.global.metadata.description | quote }}
labels:
cluster-apps-operator.giantswarm.io/watching: ""
giantswarm.io/service-priority: {{ .Values.metadata.servicePriority | quote }}
giantswarm.io/service-priority: {{ .Values.global.metadata.servicePriority | quote }}
{{- include "labels.common" . | nindent 4 }}
{{- if .Values.metadata.labels }}
{{- range $key, $val := .Values.metadata.labels }}
{{- if .Values.global.metadata.labels }}
{{- range $key, $val := .Values.global.metadata.labels }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
Expand Down
8 changes: 4 additions & 4 deletions helm/cluster-cloud-director/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ metadata:
name: {{ include "resource.default.name" $ }}
namespace: {{ .Release.Namespace }}
annotations:
cluster.giantswarm.io/description: {{ .Values.metadata.description | quote }}
cluster.giantswarm.io/description: {{ .Values.global.metadata.description | quote }}
labels:
cluster-apps-operator.giantswarm.io/watching: ""
giantswarm.io/service-priority: {{ .Values.metadata.servicePriority | quote }}
giantswarm.io/service-priority: {{ .Values.global.metadata.servicePriority | quote }}
{{- include "labels.common" . | nindent 4 }}
{{- if .Values.metadata.labels }}
{{- range $key, $val := .Values.metadata.labels }}
{{- if .Values.global.metadata.labels }}
{{- range $key, $val := .Values.global.metadata.labels }}
{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
Expand Down
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 | quote }}
cluster.giantswarm.io/description: {{ .Values.global.metadata.description | quote }}
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" $ }}-default
namespace: {{ $.Release.Namespace }}
annotations:
cluster.giantswarm.io/description: {{ .Values.metadata.description | quote }}
cluster.giantswarm.io/description: {{ .Values.global.metadata.description | quote }}
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 | quote }}
cluster.giantswarm.io/description: {{ .Values.global.metadata.description | quote }}
labels:
{{- include "labels.common" . | nindent 4 }}
spec:
Expand Down
96 changes: 48 additions & 48 deletions helm/cluster-cloud-director/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,54 @@
}
}
},
"metadata": {
"type": "object",
"title": "Metadata",
"additionalProperties": false,
"properties": {
"description": {
"type": "string",
"title": "Cluster description",
"description": "User-friendly description of the cluster's purpose."
},
"labels": {
"type": "object",
"title": "Labels",
"description": "These labels are added to the Kubernetes resources defining this cluster.",
"additionalProperties": false,
"patternProperties": {
"^[a-zA-Z0-9/\\._-]+$": {
"type": "string",
"title": "Label",
"maxLength": 63,
"minLength": 0,
"pattern": "^[a-zA-Z0-9\\._-]+$"
}
}
},
"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"
}
}
},
"podSecurityStandards": {
"type": "object",
"title": "Pod Security Standards",
Expand Down Expand Up @@ -739,54 +787,6 @@
"title": "Management cluster name",
"description": "The Cluster API management cluster that manages this cluster."
},
"metadata": {
"type": "object",
"title": "Metadata",
"additionalProperties": false,
"properties": {
"description": {
"type": "string",
"title": "Cluster description",
"description": "User-friendly description of the cluster's purpose."
},
"labels": {
"type": "object",
"title": "Labels",
"description": "These labels are added to the Kubernetes resources defining this cluster.",
"additionalProperties": false,
"patternProperties": {
"^[a-zA-Z0-9/\\._-]+$": {
"type": "string",
"title": "Label",
"maxLength": 63,
"minLength": 0,
"pattern": "^[a-zA-Z0-9\\._-]+$"
}
}
},
"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"
}
}
},
"nodePools": {
"type": "object",
"title": "Node pools",
Expand Down
6 changes: 3 additions & 3 deletions helm/cluster-cloud-director/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ global:
sudo: ALL=(ALL) NOPASSWD:ALL
sshTrustedUserCAKeys:
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIM4cvZ01fLmO9cJbWUj7sfF+NhECgy+Cl0bazSrZX7sU [email protected]
metadata:
preventDeletion: false
servicePriority: highest
podSecurityStandards:
enforced: true
internal:
Expand Down Expand Up @@ -62,9 +65,6 @@ kubectlImage:
name: giantswarm/kubectl
registry: gsoci.azurecr.io
tag: 1.25.15
metadata:
preventDeletion: false
servicePriority: highest
nodePools:
worker:
class: default
Expand Down

0 comments on commit 662c24e

Please sign in to comment.