diff --git a/charts/victoria-metrics-operator/CHANGELOG.md b/charts/victoria-metrics-operator/CHANGELOG.md index 0a46fa0a4..38c323f16 100644 --- a/charts/victoria-metrics-operator/CHANGELOG.md +++ b/charts/victoria-metrics-operator/CHANGELOG.md @@ -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 diff --git a/charts/victoria-metrics-operator/Chart.lock b/charts/victoria-metrics-operator/Chart.lock index 17c4c6d12..3b437d6e6 100644 --- a/charts/victoria-metrics-operator/Chart.lock +++ b/charts/victoria-metrics-operator/Chart.lock @@ -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" diff --git a/charts/victoria-metrics-operator/Chart.yaml b/charts/victoria-metrics-operator/Chart.yaml index 3f2413416..1d365d8c5 100644 --- a/charts/victoria-metrics-operator/Chart.yaml +++ b/charts/victoria-metrics-operator/Chart.yaml @@ -37,4 +37,4 @@ dependencies: repository: https://victoriametrics.github.io/helm-charts - name: crds version: "0.0.*" - condition: crds.enabled + condition: crds.plain diff --git a/charts/victoria-metrics-operator/charts/crds/Chart.lock b/charts/victoria-metrics-operator/charts/crds/Chart.lock new file mode 100644 index 000000000..04f8fc189 --- /dev/null +++ b/charts/victoria-metrics-operator/charts/crds/Chart.lock @@ -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" diff --git a/charts/victoria-metrics-operator/crd.yaml b/charts/victoria-metrics-operator/crd.yaml new file mode 120000 index 000000000..1ff428922 --- /dev/null +++ b/charts/victoria-metrics-operator/crd.yaml @@ -0,0 +1 @@ +charts/crds/crds/crd.yaml \ No newline at end of file diff --git a/charts/victoria-metrics-operator/templates/_helpers.tpl b/charts/victoria-metrics-operator/templates/_helpers.tpl index d11498db9..4c8a9c85c 100644 --- a/charts/victoria-metrics-operator/templates/_helpers.tpl +++ b/charts/victoria-metrics-operator/templates/_helpers.tpl @@ -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" . }} diff --git a/charts/victoria-metrics-operator/templates/crd.yaml b/charts/victoria-metrics-operator/templates/crd.yaml new file mode 100644 index 000000000..9d14beecb --- /dev/null +++ b/charts/victoria-metrics-operator/templates/crd.yaml @@ -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 }} diff --git a/charts/victoria-metrics-operator/values.yaml b/charts/victoria-metrics-operator/values.yaml index 4f6700e06..0a8796d19 100644 --- a/charts/victoria-metrics-operator/values.yaml +++ b/charts/victoria-metrics-operator/values.yaml @@ -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