From 3cef351487a696229f37ddbbcaa5973c2b4b2cc5 Mon Sep 17 00:00:00 2001 From: Kiran Mova Date: Sat, 17 Jul 2021 00:21:38 +0530 Subject: [PATCH] fix(helm): configure version for snapshot api (#361) On some managed K8s clusters like OpenShift or GKE that ship with their own default CSI Drivers, the controllers will end up creating v1beta1 objects. An issue like the following was noticed when running cstor charts on GKE 1.19. ``` unable to recognize "": no matches for kind "VolumeSnapshotClass" in version "snapshot.storage.k8s.io/v1" ``` This commit uses the helm .Capabilities to check the version available in the cluster and install the class accordingly. As the .Capabilities might return false when using with template command, v1 is kept for false (or default) case. Signed-off-by: kmova --- deploy/helm/charts/Chart.yaml | 2 +- deploy/helm/charts/README.md | 1 - deploy/helm/charts/templates/snapshot-class.yaml | 8 ++++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/deploy/helm/charts/Chart.yaml b/deploy/helm/charts/Chart.yaml index 9eb5160b..6208e14d 100644 --- a/deploy/helm/charts/Chart.yaml +++ b/deploy/helm/charts/Chart.yaml @@ -4,7 +4,7 @@ description: CStor-Operator helm chart for Kubernetes type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. -version: 2.11.0 +version: 2.11.1 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. appVersion: 2.11.0 diff --git a/deploy/helm/charts/README.md b/deploy/helm/charts/README.md index 06f7b18e..43eaa3bd 100644 --- a/deploy/helm/charts/README.md +++ b/deploy/helm/charts/README.md @@ -238,4 +238,3 @@ helm install openebs-cstor openebs-cstor/cstor --namespace openebs --create-name | serviceAccount.csiController.name | string | `"openebs-cstor-csi-controller-sa"` | CSI Controller ServiceAccount name | | serviceAccount.csiNode.create | bool | `true` | Enable CSI Node ServiceAccount | | serviceAccount.csiNode.name | string | `"openebs-cstor-csi-node-sa"` | CSI Node ServiceAccount name | - diff --git a/deploy/helm/charts/templates/snapshot-class.yaml b/deploy/helm/charts/templates/snapshot-class.yaml index 6418d0d8..f70003fe 100644 --- a/deploy/helm/charts/templates/snapshot-class.yaml +++ b/deploy/helm/charts/templates/snapshot-class.yaml @@ -1,8 +1,12 @@ kind: VolumeSnapshotClass -apiVersion: snapshot.storage.k8s.io/v1 +apiVersion: {{ if .Capabilities.APIVersions.Has "snapshot.storage.k8s.io/v1beta1" -}} + snapshot.storage.k8s.io/v1beta1 +{{- else -}} + snapshot.storage.k8s.io/v1 +{{- end }} metadata: name: csi-cstor-snapshotclass annotations: snapshot.storage.kubernetes.io/is-default-class: "true" driver: cstor.csi.openebs.io -deletionPolicy: Delete \ No newline at end of file +deletionPolicy: Delete