Skip to content

Commit cd7e9b7

Browse files
fix: crds getting removed on helm upgrades (#289)
* fix: crds getting removed on helm upgrades Signed-off-by: Abhinandan Purkait <[email protected]> * fix: crds getting removed on helm upgrades Signed-off-by: Abhinandan Purkait <[email protected]> * chore: add condition for the crds subchart Signed-off-by: Abhinandan Purkait <[email protected]> * feat(chart): remove quotes from version Signed-off-by: Abhinandan Purkait <[email protected]> * feat(chart): update README Signed-off-by: Abhinandan Purkait <[email protected]> --------- Signed-off-by: Abhinandan Purkait <[email protected]>
1 parent 731233a commit cd7e9b7

13 files changed

+34
-42
lines changed

ct.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ target-branch: develop
44
chart-dirs:
55
- deploy/helm
66
helm-extra-args: --timeout=500s
7+
validate-maintainers: false

deploy/helm/charts/Chart.yaml

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v2
22
name: lvm-localpv
33
description: CSI Driver for dynamic provisioning of LVM Persistent Local Volumes.
4-
version: 1.5.0
4+
version: 1.5.1
55
appVersion: 1.5.0
66
icon: https://raw.githubusercontent.com/cncf/artwork/master/projects/openebs/icon/color/openebs-icon-color.png
77
home: https://openebs.io/
@@ -16,11 +16,5 @@ sources:
1616
- https://github.com/openebs/lvm-localpv
1717
dependencies:
1818
- name: crds
19-
version: "1.5.0"
20-
maintainers:
21-
- name: prateekpandey14
22-
23-
- name: pawanpraka1
24-
25-
- name: iyashu
26-
19+
version: 1.5.1
20+
condition: crds.enabled

deploy/helm/charts/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ helm install openebs-lvmlocalpv openebs-lvmlocalpv/lvm-localpv --namespace opene
101101
| `lvmPlugin.image.registry` | Registry for openebs-lvm-plugin image | `""` |
102102
| `lvmPlugin.image.repository` | Image repository for openebs-lvm-plugin | `openebs/lvm-driver` |
103103
| `lvmPlugin.image.pullPolicy` | Image pull policy for openebs-lvm-plugin | `IfNotPresent` |
104-
| `lvmPlugin.image.tag` | Image tag for openebs-lvm-plugin | `1.3.0` |
104+
| `lvmPlugin.image.tag` | Image tag for openebs-lvm-plugin | `1.5.0` |
105105
| `lvmPlugin.metricsPort` | The TCP port number used for exposing lvm-metrics | `9500` |
106106
| `lvmPlugin.allowedTopologies` | The comma seperated list of allowed node topologies | `kubernetes.io/hostname,` |
107107
| `lvmNode.driverRegistrar.image.registry` | Registry for csi-node-driver-registrar image | `registry.k8s.io/` |
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
apiVersion: v2
22
name: crds
3-
version: 1.5.0
3+
version: 1.5.1
44
description: A Helm chart that collects CustomResourceDefinitions (CRDs) from lvm-localpv.
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
13
{{/*
2-
This returns a "1" if the CRD is absent in the cluster
4+
Adds extra annotations to CRDs. This targets two scenarios: preventing CRD recycling in case
5+
the chart is removed; and adding custom annotations.
6+
NOTE: This function assumes the element `metadata.annotations` already exists.
37
Usage:
4-
{{- if (include "crdIsAbsent" (list <crd-name>)) -}}
5-
# CRD Yaml
6-
{{- end -}}
8+
{{- include "crds.extraAnnotations" .Values.csi.volumeSnapshots | nindent 4 }}
79
*/}}
8-
{{- define "crdIsAbsent" -}}
9-
{{- $crdName := index . 0 -}}
10-
{{- $crd := lookup "apiextensions.k8s.io/v1" "CustomResourceDefinition" "" $crdName -}}
11-
{{- $output := "1" -}}
12-
{{- if $crd -}}
13-
{{- $output = "" -}}
14-
{{- end -}}
1510

16-
{{- $output -}}
11+
{{- define "crds.extraAnnotations" -}}
12+
{{- if .keep -}}
13+
helm.sh/resource-policy: keep
14+
{{ end }}
15+
{{- with .annotations }}
16+
{{- toYaml . }}
17+
{{- end }}
1718
{{- end -}}

deploy/helm/charts/charts/crds/templates/csi-volume-snapshot-class.yaml

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
{{- if .Values.csi.volumeSnapshots.enabled -}}
2-
{{- $crdName := "volumesnapshotclasses.snapshot.storage.k8s.io" -}}
3-
{{- if (include "crdIsAbsent" (list $crdName)) -}}
42
apiVersion: apiextensions.k8s.io/v1
53
kind: CustomResourceDefinition
64
metadata:
75
annotations:
86
api-approved.kubernetes.io: https://github.com/kubernetes-csi/external-snapshotter/pull/814
97
controller-gen.kubebuilder.io/version: v0.11.3
8+
{{- include "crds.extraAnnotations" .Values.csi.volumeSnapshots | nindent 4 }}
109
creationTimestamp: null
1110
name: volumesnapshotclasses.snapshot.storage.k8s.io
1211
spec:
@@ -148,5 +147,4 @@ status:
148147
plural: ""
149148
conditions: []
150149
storedVersions: []
151-
{{- end -}}
152150
{{- end -}}

deploy/helm/charts/charts/crds/templates/csi-volume-snapshot-content.yaml

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
{{- if .Values.csi.volumeSnapshots.enabled -}}
2-
{{- $crdName := "volumesnapshotcontents.snapshot.storage.k8s.io" -}}
3-
{{- if (include "crdIsAbsent" (list $crdName)) -}}
42
apiVersion: apiextensions.k8s.io/v1
53
kind: CustomResourceDefinition
64
metadata:
75
annotations:
86
api-approved.kubernetes.io: https://github.com/kubernetes-csi/external-snapshotter/pull/814
97
controller-gen.kubebuilder.io/version: v0.11.3
8+
{{- include "crds.extraAnnotations" .Values.csi.volumeSnapshots | nindent 4 }}
109
creationTimestamp: null
1110
name: volumesnapshotcontents.snapshot.storage.k8s.io
1211
spec:
@@ -486,5 +485,4 @@ status:
486485
plural: ""
487486
conditions: []
488487
storedVersions: []
489-
{{- end -}}
490488
{{- end -}}

deploy/helm/charts/charts/crds/templates/csi-volume-snapshot.yaml

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
{{- if .Values.csi.volumeSnapshots.enabled -}}
2-
{{- $crdName := "volumesnapshots.snapshot.storage.k8s.io" -}}
3-
{{- if (include "crdIsAbsent" (list $crdName)) -}}
42
apiVersion: apiextensions.k8s.io/v1
53
kind: CustomResourceDefinition
64
metadata:
75
annotations:
86
api-approved.kubernetes.io: https://github.com/kubernetes-csi/external-snapshotter/pull/814
97
controller-gen.kubebuilder.io/version: v0.11.3
8+
{{- include "crds.extraAnnotations" .Values.csi.volumeSnapshots | nindent 4 }}
109
creationTimestamp: null
1110
name: volumesnapshots.snapshot.storage.k8s.io
1211
spec:
@@ -388,5 +387,4 @@ status:
388387
plural: ""
389388
conditions: []
390389
storedVersions: []
391-
{{- end -}}
392390
{{- end -}}

deploy/helm/charts/charts/crds/templates/lvmnode.yaml

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{{- if .Values.lvmLocalPv.enabled -}}
2-
{{- $crdName := "lvmnodes.local.openebs.io" -}}
3-
{{- if (include "crdIsAbsent" (list $crdName)) -}}
42
##############################################
53
########### ############
64
########### LVMNode CRD ############
@@ -17,6 +15,7 @@ kind: CustomResourceDefinition
1715
metadata:
1816
annotations:
1917
controller-gen.kubebuilder.io/version: v0.4.0
18+
{{- include "crds.extraAnnotations" .Values.lvmLocalPv | nindent 4 }}
2019
creationTimestamp: null
2120
name: lvmnodes.local.openebs.io
2221
spec:
@@ -176,5 +175,4 @@ status:
176175
plural: ""
177176
conditions: []
178177
storedVersions: []
179-
{{- end -}}
180178
{{- end -}}

deploy/helm/charts/charts/crds/templates/lvmsnapshot.yaml

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{{- if .Values.lvmLocalPv.enabled -}}
2-
{{- $crdName := "lvmsnapshots.local.openebs.io" -}}
3-
{{- if (include "crdIsAbsent" (list $crdName)) -}}
42
##############################################
53
########### ############
64
########### LVMSnapshot CRD ############
@@ -17,6 +15,7 @@ kind: CustomResourceDefinition
1715
metadata:
1816
annotations:
1917
controller-gen.kubebuilder.io/version: v0.4.0
18+
{{- include "crds.extraAnnotations" .Values.lvmLocalPv | nindent 4 }}
2019
creationTimestamp: null
2120
name: lvmsnapshots.local.openebs.io
2221
spec:
@@ -84,5 +83,4 @@ status:
8483
plural: ""
8584
conditions: []
8685
storedVersions: []
87-
{{- end -}}
8886
{{- end -}}

deploy/helm/charts/charts/crds/templates/lvmvolume.yaml

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{{- if .Values.lvmLocalPv.enabled -}}
2-
{{- $crdName := "lvmvolumes.local.openebs.io" -}}
3-
{{- if (include "crdIsAbsent" (list $crdName)) -}}
42
##############################################
53
########### ############
64
########### LVMVolume CRD ############
@@ -17,6 +15,7 @@ kind: CustomResourceDefinition
1715
metadata:
1816
annotations:
1917
controller-gen.kubebuilder.io/version: v0.4.0
18+
{{- include "crds.extraAnnotations" .Values.lvmLocalPv | nindent 4 }}
2019
creationTimestamp: null
2120
name: lvmvolumes.local.openebs.io
2221
spec:
@@ -152,5 +151,4 @@ status:
152151
plural: ""
153152
conditions: []
154153
storedVersions: []
155-
{{- end -}}
156154
{{- end -}}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
lvmLocalPv:
22
# Install lvm-localpv CRDs
33
enabled: true
4+
# Keep CRDs on chart uninstall
5+
keep: true
46

57
csi:
68
volumeSnapshots:
79
# Install Volume Snapshot CRDs
810
enabled: true
11+
# Keep CRDs on chart uninstall
12+
keep: true

deploy/helm/charts/values.yaml

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This is a YAML-formatted file.
33
# Declare variables to be passed into your templates.
44
release:
5-
version: "1.5.0"
5+
version: "1.5.1"
66

77
imagePullSecrets:
88
# - name: "image-pull-secret"
@@ -187,7 +187,11 @@ crds:
187187
lvmLocalPv:
188188
# Install lvm-localpv CRDs
189189
enabled: true
190+
# Keep CRDs on chart uninstall
191+
keep: true
190192
csi:
191193
volumeSnapshots:
192194
# Install Volume Snapshot CRDs
193195
enabled: true
196+
# Keep CRDs on chart uninstall
197+
keep: true

0 commit comments

Comments
 (0)