Skip to content

Commit

Permalink
select if CRDs should be rendered as plain or as templates
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewChubatiuk committed Sep 12, 2024
1 parent 116fedc commit 57c9ae5
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion charts/victoria-metrics-operator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Next release

- Moved crds to a shared chart and import them as a dependency
- replaced `crd.*` properties to `crds.*` as they now belong to a subchart
- replaced `crd.enabled` property to `crds.plain`. Instead of disabling CRDs it selects if CRDs should be rendered from template or as plain CRDs

## 0.34.8

Expand Down
6 changes: 3 additions & 3 deletions charts/victoria-metrics-operator/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
dependencies:
- name: victoria-metrics-common
repository: https://victoriametrics.github.io/helm-charts
version: 0.0.10
version: 0.0.11
- name: crds
repository: ""
version: 0.0.*
digest: sha256:86d9756bb19f2d2eb21e119f201b25b6c00f443b0ac2aa6f4d51fb71453d159a
generated: "2024-09-11T09:25:01.502701+03:00"
digest: sha256:69e95492bf4124e524b99335c1bc02dc4b10b96105f3d5362a042d4985aab3cf
generated: "2024-09-12T12:47:05.668035+03:00"
2 changes: 1 addition & 1 deletion charts/victoria-metrics-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ dependencies:
repository: https://victoriametrics.github.io/helm-charts
- name: crds
version: "0.0.*"
condition: crds.enabled
condition: crds.plain
6 changes: 6 additions & 0 deletions charts/victoria-metrics-operator/charts/crds/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: victoria-metrics-common
repository: https://victoriametrics.github.io/helm-charts
version: 0.0.11
digest: sha256:d91f2afa5ae37158f11b1c6601cf8265b08dad62ec4eefd36064b32946e215a6
generated: "2024-09-12T11:55:35.84919+03:00"
1 change: 1 addition & 0 deletions charts/victoria-metrics-operator/crd.yaml
2 changes: 1 addition & 1 deletion charts/victoria-metrics-operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ app.kubernetes.io/managed-by: {{ $Release.Service | trunc 63 | trimSuffix "-" }}
{{/*
Create unified annotations for vm-operator components
*/}}
{{- define "vm-operator.annotations" -}}
{{- define "vm-operator.crds.annotations" -}}
{{- $Release :=(.helm).Release | default .Release -}}
helm.sh/resource-policy: keep
meta.helm.sh/release-namespace: {{ include "vm.namespace" . }}
Expand Down
15 changes: 15 additions & 0 deletions charts/victoria-metrics-operator/templates/crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- /* do not update crds here, please update in /victoria-metrics-operator/crd.yaml */ -}}
{{- /* this is used to add "helm.sh/resource-policy: keep" annotation for each crd */ -}}
{{- /* see this pull request https://github.com/VictoriaMetrics/helm-charts/pull/771 for details */ -}}
{{- if not .Values.crds.plain }}
{{- $files := .Files }}
{{- $crds := $files.Get "crd.yaml" | splitList "---" }}
{{- $labels := (include "vm-operator.labels" .) | fromYaml -}}
{{- $annotations := (include "vm-operator.crds.annotations" .) | fromYaml -}}
{{- $extra := dict "metadata" (dict "annotations" $annotations "labels" $labels) -}}
{{- range $crds }}
{{- $crd := . | fromYaml }}
{{- toYaml (merge $crd $extra) }}
{{- print "\n---\n" }}
{{- end }}
{{- end }}
7 changes: 4 additions & 3 deletions charts/victoria-metrics-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ image:
pullPolicy: IfNotPresent

crds:
# -- enables CRD creation and management.
# -- with this option, if you remove this chart, all crd resources will be deleted with it.
enabled: true
# -- check if plain or templated CRDs should be created.
# with this option set to `false`, all CRDs will be rendered from templates.
# with this option set to `true`, all CRDs are immutable and require manual upgrade.
plain: false
cleanup:
# -- Tells helm to clean up all the vm resources under this release's namespace when uninstalling
enabled: false
Expand Down

0 comments on commit 57c9ae5

Please sign in to comment.