Skip to content

Commit

Permalink
fix: crds getting removed on helm upgrades (#519)
Browse files Browse the repository at this point in the history
* fix: crds getting removed on helm upgrades

Signed-off-by: Abhinandan Purkait <purkaitabhinandan@gmail.com>

* chore: add condition for the crds subchart

Signed-off-by: Abhinandan Purkait <purkaitabhinandan@gmail.com>

* feat(chart): update README

Signed-off-by: Abhinandan Purkait <purkaitabhinandan@gmail.com>

---------

Signed-off-by: Abhinandan Purkait <purkaitabhinandan@gmail.com>
  • Loading branch information
Abhinandan-Purkait committed Apr 16, 2024
1 parent d99b0a0 commit 6d3d2ce
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 41 deletions.
5 changes: 3 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,5 @@ sources:
- https://github.com/openebs/zfs-localpv
dependencies:
- name: crds
version: "2.5.0"
version: 2.5.1
condition: crds.enabled
2 changes: 1 addition & 1 deletion deploy/helm/charts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ The following table lists the configurable parameters of the OpenEBS ZFS Localpv
| `zfsPlugin.image.registry`| Registry for openebs-zfs-plugin image| `""`|
| `zfsPlugin.image.repository`| Image repository for openebs-zfs-plugin| `openebs/zfs-driver`|
| `zfsPlugin.image.pullPolicy`| Image pull policy for openebs-zfs-plugin| `IfNotPresent`|
| `zfsPlugin.image.tag`| Image tag for openebs-zfs-plugin| `2.3.0`|
| `zfsPlugin.image.tag`| Image tag for openebs-zfs-plugin| `2.5.0`|
| `zfsNode.allowedTopologyKeys`| Custom topology keys required for provisioning| `"kubernetes.io/hostname,"`|
| `zfsNode.driverRegistrar.image.registry`| Registry for csi-node-driver-registrar image| `registry.k8s.io/`|
| `zfsNode.driverRegistrar.image.repository`| Image repository for csi-node-driver-registrar| `sig-storage/csi-node-driver-registrar`|
Expand Down
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.
26 changes: 14 additions & 12 deletions deploy/helm/charts/charts/crds/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
{{/* vim: set filetype=mustache: */}}

{{/*
This returns a "1" if the CRD is absent in the cluster
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:
{{- if (include "crdIsAbsent" (list <crd-name>)) -}}
# CRD Yaml
{{- end -}}
{{- include "crds.extraAnnotations" .Values.csi.volumeSnapshots | nindent 4 }}
*/}}
{{- define "crdIsAbsent" -}}
{{- $crdName := index . 0 -}}
{{- $crd := lookup "apiextensions.k8s.io/v1" "CustomResourceDefinition" "" $crdName -}}
{{- $output := "1" -}}
{{- if $crd -}}
{{- $output = "" -}}
{{- end -}}

{{- $output -}}
{{- 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 -}}
4 changes: 1 addition & 3 deletions deploy/helm/charts/charts/crds/templates/zfsbackup.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{- if .Values.zfsLocalPv.enabled -}}
{{- $crdName := "zfsbackups.zfs.openebs.io" -}}
{{- if (include "crdIsAbsent" (list $crdName)) -}}
##############################################
########### ############
########### ZFSBackup CRD ############
Expand All @@ -17,6 +15,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 Expand Up @@ -115,5 +114,4 @@ status:
plural: ""
conditions: []
storedVersions: []
{{- end -}}
{{- end -}}
4 changes: 1 addition & 3 deletions deploy/helm/charts/charts/crds/templates/zfsnode.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{- if .Values.zfsLocalPv.enabled -}}
{{- $crdName := "zfsnodes.zfs.openebs.io" -}}
{{- if (include "crdIsAbsent" (list $crdName)) -}}
##############################################
########### ############
########### ZFSNode CRD ############
Expand All @@ -17,6 +15,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 Expand Up @@ -95,5 +94,4 @@ status:
plural: ""
conditions: []
storedVersions: []
{{- end -}}
{{- end -}}
4 changes: 1 addition & 3 deletions deploy/helm/charts/charts/crds/templates/zfsrestore.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{- if .Values.zfsLocalPv.enabled -}}
{{- $crdName := "zfsrestores.zfs.openebs.io" -}}
{{- if (include "crdIsAbsent" (list $crdName)) -}}
##############################################
########### ############
########### ZFSRestore CRD ############
Expand All @@ -17,6 +15,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 Expand Up @@ -237,5 +236,4 @@ status:
plural: ""
conditions: []
storedVersions: []
{{- end -}}
{{- end -}}
4 changes: 1 addition & 3 deletions deploy/helm/charts/charts/crds/templates/zfssnapshot.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{- if .Values.zfsLocalPv.enabled -}}
{{- $crdName := "zfssnapshots.zfs.openebs.io" -}}
{{- if (include "crdIsAbsent" (list $crdName)) -}}
##############################################
########### ############
########### ZFSSnapshot CRD ############
Expand All @@ -17,6 +15,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 Expand Up @@ -382,5 +381,4 @@ status:
plural: ""
conditions: []
storedVersions: []
{{- end -}}
{{- end -}}
4 changes: 1 addition & 3 deletions deploy/helm/charts/charts/crds/templates/zfsvolume.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{- if .Values.zfsLocalPv.enabled -}}
{{- $crdName := "zfsvolumes.zfs.openebs.io" -}}
{{- if (include "crdIsAbsent" (list $crdName)) -}}
##############################################
########### ############
########### ZFSVolume CRD ############
Expand All @@ -17,6 +15,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 Expand Up @@ -448,5 +447,4 @@ status:
plural: ""
conditions: []
storedVersions: []
{{- end -}}
{{- end -}}
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 6d3d2ce

Please sign in to comment.