Skip to content

Commit

Permalink
fix: crds getting removed on helm upgrades (#289)
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>

* 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): remove quotes from version

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 authored Apr 16, 2024
1 parent 731233a commit cd7e9b7
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 42 deletions.
1 change: 1 addition & 0 deletions ct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ target-branch: develop
chart-dirs:
- deploy/helm
helm-extra-args: --timeout=500s
validate-maintainers: false
12 changes: 3 additions & 9 deletions deploy/helm/charts/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: lvm-localpv
description: CSI Driver for dynamic provisioning of LVM Persistent Local Volumes.
version: 1.5.0
version: 1.5.1
appVersion: 1.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,11 +16,5 @@ sources:
- https://github.com/openebs/lvm-localpv
dependencies:
- name: crds
version: "1.5.0"
maintainers:
- name: prateekpandey14
email: prateek.pandey@mayadata.io
- name: pawanpraka1
email: pawan@mayadata.io
- name: iyashu
email: yashpal.c1995@gmail.com
version: 1.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 @@ -101,7 +101,7 @@ helm install openebs-lvmlocalpv openebs-lvmlocalpv/lvm-localpv --namespace opene
| `lvmPlugin.image.registry` | Registry for openebs-lvm-plugin image | `""` |
| `lvmPlugin.image.repository` | Image repository for openebs-lvm-plugin | `openebs/lvm-driver` |
| `lvmPlugin.image.pullPolicy` | Image pull policy for openebs-lvm-plugin | `IfNotPresent` |
| `lvmPlugin.image.tag` | Image tag for openebs-lvm-plugin | `1.3.0` |
| `lvmPlugin.image.tag` | Image tag for openebs-lvm-plugin | `1.5.0` |
| `lvmPlugin.metricsPort` | The TCP port number used for exposing lvm-metrics | `9500` |
| `lvmPlugin.allowedTopologies` | The comma seperated list of allowed node topologies | `kubernetes.io/hostname,` |
| `lvmNode.driverRegistrar.image.registry` | Registry for csi-node-driver-registrar image | `registry.k8s.io/` |
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: 1.5.0
version: 1.5.1
description: A Helm chart that collects CustomResourceDefinitions (CRDs) from lvm-localpv.
25 changes: 13 additions & 12 deletions deploy/helm/charts/charts/crds/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
{{/* 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/lvmnode.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{- if .Values.lvmLocalPv.enabled -}}
{{- $crdName := "lvmnodes.local.openebs.io" -}}
{{- if (include "crdIsAbsent" (list $crdName)) -}}
##############################################
########### ############
########### LVMNode CRD ############
Expand All @@ -17,6 +15,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.0
{{- include "crds.extraAnnotations" .Values.lvmLocalPv | nindent 4 }}
creationTimestamp: null
name: lvmnodes.local.openebs.io
spec:
Expand Down Expand Up @@ -176,5 +175,4 @@ status:
plural: ""
conditions: []
storedVersions: []
{{- end -}}
{{- end -}}
4 changes: 1 addition & 3 deletions deploy/helm/charts/charts/crds/templates/lvmsnapshot.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{- if .Values.lvmLocalPv.enabled -}}
{{- $crdName := "lvmsnapshots.local.openebs.io" -}}
{{- if (include "crdIsAbsent" (list $crdName)) -}}
##############################################
########### ############
########### LVMSnapshot CRD ############
Expand All @@ -17,6 +15,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.0
{{- include "crds.extraAnnotations" .Values.lvmLocalPv | nindent 4 }}
creationTimestamp: null
name: lvmsnapshots.local.openebs.io
spec:
Expand Down Expand Up @@ -84,5 +83,4 @@ status:
plural: ""
conditions: []
storedVersions: []
{{- end -}}
{{- end -}}
4 changes: 1 addition & 3 deletions deploy/helm/charts/charts/crds/templates/lvmvolume.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{- if .Values.lvmLocalPv.enabled -}}
{{- $crdName := "lvmvolumes.local.openebs.io" -}}
{{- if (include "crdIsAbsent" (list $crdName)) -}}
##############################################
########### ############
########### LVMVolume CRD ############
Expand All @@ -17,6 +15,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.0
{{- include "crds.extraAnnotations" .Values.lvmLocalPv | nindent 4 }}
creationTimestamp: null
name: lvmvolumes.local.openebs.io
spec:
Expand Down Expand Up @@ -152,5 +151,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 @@
lvmLocalPv:
# Install lvm-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
6 changes: 5 additions & 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: "1.5.0"
version: "1.5.1"

imagePullSecrets:
# - name: "image-pull-secret"
Expand Down Expand Up @@ -187,7 +187,11 @@ crds:
lvmLocalPv:
# Install lvm-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

0 comments on commit cd7e9b7

Please sign in to comment.