Skip to content

Commit

Permalink
fix: crds getting removed on helm upgrades
Browse files Browse the repository at this point in the history
Signed-off-by: Abhinandan Purkait <purkaitabhinandan@gmail.com>
  • Loading branch information
Abhinandan-Purkait committed Mar 27, 2024
1 parent 4600558 commit 008e5c0
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 13 deletions.
4 changes: 2 additions & 2 deletions deploy/helm/charts/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: zfs-localpv
description: Helm chart for CSI Driver for dynamic provisioning of ZFS Persistent Local Volumes. For instructions on how to use this helm chart, see - https://openebs.github.io/zfs-localpv/
version: 2.5.0
version: 2.5.1
appVersion: 2.5.0
icon: https://raw.githubusercontent.com/cncf/artwork/master/projects/openebs/icon/color/openebs-icon-color.png
home: https://openebs.io/
Expand All @@ -16,4 +16,4 @@ sources:
- https://github.com/openebs/zfs-localpv
dependencies:
- name: crds
version: "2.5.0"
version: "2.5.1"
2 changes: 1 addition & 1 deletion deploy/helm/charts/charts/crds/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: v2
name: crds
version: 2.5.0
version: 2.5.1
description: A Helm chart that collects CustomResourceDefinitions (CRDs) from zfs-localpv.
20 changes: 20 additions & 0 deletions deploy/helm/charts/charts/crds/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{/* vim: set filetype=mustache: */}}

{{/*
This returns a "1" if the CRD is absent in the cluster
Usage:
Expand All @@ -14,4 +16,22 @@
{{- end -}}

{{- $output -}}
{{- end -}}

{{/*
Adds extra annotations to CRDs. This targets two scenarios: preventing CRD recycling in case
the chart is removed; and adding custom annotations.
NOTE: This function assumes the element `metadata.annotations` already exists.
Usage:
{{- include "crds.extraAnnotations" .Values.csi.volumeSnapshots | nindent 4 }}
*/}}

{{- define "crds.extraAnnotations" -}}
{{- if .keep -}}
helm.sh/resource-policy: keep
{{ end }}
{{- with .annotations }}
{{- toYaml . }}
{{- end }}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{{- if .Values.csi.volumeSnapshots.enabled -}}
{{- $crdName := "volumesnapshotclasses.snapshot.storage.k8s.io" -}}
{{- if (include "crdIsAbsent" (list $crdName)) -}}
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
api-approved.kubernetes.io: https://github.com/kubernetes-csi/external-snapshotter/pull/814
controller-gen.kubebuilder.io/version: v0.11.3
{{- include "crds.extraAnnotations" .Values.csi.volumeSnapshots | nindent 4 }}
creationTimestamp: null
name: volumesnapshotclasses.snapshot.storage.k8s.io
spec:
Expand Down Expand Up @@ -148,5 +147,4 @@ status:
plural: ""
conditions: []
storedVersions: []
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{{- if .Values.csi.volumeSnapshots.enabled -}}
{{- $crdName := "volumesnapshotcontents.snapshot.storage.k8s.io" -}}
{{- if (include "crdIsAbsent" (list $crdName)) -}}
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
api-approved.kubernetes.io: https://github.com/kubernetes-csi/external-snapshotter/pull/814
controller-gen.kubebuilder.io/version: v0.11.3
{{- include "crds.extraAnnotations" .Values.csi.volumeSnapshots | nindent 4 }}
creationTimestamp: null
name: volumesnapshotcontents.snapshot.storage.k8s.io
spec:
Expand Down Expand Up @@ -486,5 +485,4 @@ status:
plural: ""
conditions: []
storedVersions: []
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{{- if .Values.csi.volumeSnapshots.enabled -}}
{{- $crdName := "volumesnapshots.snapshot.storage.k8s.io" -}}
{{- if (include "crdIsAbsent" (list $crdName)) -}}
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
api-approved.kubernetes.io: https://github.com/kubernetes-csi/external-snapshotter/pull/814
controller-gen.kubebuilder.io/version: v0.11.3
{{- include "crds.extraAnnotations" .Values.csi.volumeSnapshots | nindent 4 }}
creationTimestamp: null
name: volumesnapshots.snapshot.storage.k8s.io
spec:
Expand Down Expand Up @@ -388,5 +387,4 @@ status:
plural: ""
conditions: []
storedVersions: []
{{- end -}}
{{- end -}}
1 change: 1 addition & 0 deletions deploy/helm/charts/charts/crds/templates/zfsbackup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.0
{{- include "crds.extraAnnotations" .Values.zfsLocalPv | nindent 4 }}
creationTimestamp: null
name: zfsbackups.zfs.openebs.io
spec:
Expand Down
1 change: 1 addition & 0 deletions deploy/helm/charts/charts/crds/templates/zfsnode.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.0
{{- include "crds.extraAnnotations" .Values.zfsLocalPv | nindent 4 }}
creationTimestamp: null
name: zfsnodes.zfs.openebs.io
spec:
Expand Down
1 change: 1 addition & 0 deletions deploy/helm/charts/charts/crds/templates/zfsrestore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.0
{{- include "crds.extraAnnotations" .Values.zfsLocalPv | nindent 4 }}
creationTimestamp: null
name: zfsrestores.zfs.openebs.io
spec:
Expand Down
1 change: 1 addition & 0 deletions deploy/helm/charts/charts/crds/templates/zfssnapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.0
{{- include "crds.extraAnnotations" .Values.zfsLocalPv | nindent 4 }}
creationTimestamp: null
name: zfssnapshots.zfs.openebs.io
spec:
Expand Down
1 change: 1 addition & 0 deletions deploy/helm/charts/charts/crds/templates/zfsvolume.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.0
{{- include "crds.extraAnnotations" .Values.zfsLocalPv | nindent 4 }}
creationTimestamp: null
name: zfsvolumes.zfs.openebs.io
spec:
Expand Down
4 changes: 4 additions & 0 deletions deploy/helm/charts/charts/crds/values.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
zfsLocalPv:
# Install zfs-localpv CRDs
enabled: true
# -- Keep CRDs on chart uninstall
keep: true

csi:
volumeSnapshots:
# Install Volume Snapshot CRDs
enabled: true
# -- Keep CRDs on chart uninstall
keep: true
2 changes: 1 addition & 1 deletion deploy/helm/charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
release:
version: "2.5.0"
version: "2.5.1"

imagePullSecrets:
# - name: "image-pull-secret"
Expand Down

0 comments on commit 008e5c0

Please sign in to comment.