From 93d99dabc4958f7feaf17e3b8eab1f9027bce2fe Mon Sep 17 00:00:00 2001 From: jichenjc Date: Mon, 16 Mar 2020 03:29:03 +0000 Subject: [PATCH] upgrade snapshot to v2.0.1 https://github.com/kubernetes-csi/external-snapshotter/releases has a broken update when upgrade to 2.0.0 so the upgrade of the side car container including: 1) upgrade the version 2) honor the split of snapshot controller and snapshotter 3) update rbac 4) update example according to the v1beta1 definition --- docs/using-cinder-csi-plugin.md | 8 +++++--- examples/cinder-csi-plugin/snapshot/example.yaml | 5 +++-- .../cinder-csi-plugin/snapshot/snapshotcreate.yaml | 7 +++---- .../cinder-csi-controllerplugin-rbac.yaml | 3 +++ .../cinder-csi-controllerplugin.yaml | 9 ++------- .../cinder-csi-plugin/cinder-csi-nodeplugin-rbac.yaml | 10 +++++++++- .../cinder-csi-plugin/cinder-csi-nodeplugin.yaml | 11 +++++++++++ 7 files changed, 36 insertions(+), 17 deletions(-) diff --git a/docs/using-cinder-csi-plugin.md b/docs/using-cinder-csi-plugin.md index 5d961f7db0..3f755db10d 100644 --- a/docs/using-cinder-csi-plugin.md +++ b/docs/using-cinder-csi-plugin.md @@ -68,8 +68,8 @@ You should make sure following similar pods are ready before proceed: ``` NAME READY STATUS RESTARTS AGE -csi-cinder-controllerplugin 4/4 Running 0 29h -csi-cinder-nodeplugin 2/2 Running 0 46h +csi-cinder-controllerplugin 5/5 Running 0 29h +csi-cinder-nodeplugin 3/3 Running 0 46h ``` you can get information about CSI Drivers running in a cluster, using **CSIDriver** object @@ -195,7 +195,9 @@ Note: `allowedTopologies` can be specified in storage class to restrict the topo Following prerequisite needed for volume snapshot feature to work. 1. Enable `--feature-gates=VolumeSnapshotDataSource=true` in kube-apiserver -2. Make sure, your csi deployment contains external-snapshotter sidecar container, external-snapshotter sidecar container will create three crd's for snapshot management VolumeSnapshot,VolumeSnapshotContent, and VolumeSnapshotClass. external-snapshotter is a part of `csi-cinder-controllerplugin` +2. Make sure, your csi deployment contains external-snapshotter sidecar container +3. Download yaml files from https://github.com/kubernetes-csi/external-snapshotter/tree/v2.0.1/config/crd +4. Apply all yaml files downloaded at step 3) by using `kubectl apply -f ` command, as currently there is no released yaml file from `external-snapshotter` community. For Snapshot Creation and Volume Restore, please follow below steps: diff --git a/examples/cinder-csi-plugin/snapshot/example.yaml b/examples/cinder-csi-plugin/snapshot/example.yaml index ea74b4ae88..d72599b94d 100644 --- a/examples/cinder-csi-plugin/snapshot/example.yaml +++ b/examples/cinder-csi-plugin/snapshot/example.yaml @@ -6,11 +6,12 @@ provisioner: cinder.csi.openstack.org --- -apiVersion: snapshot.storage.k8s.io/v1alpha1 +apiVersion: snapshot.storage.k8s.io/v1beta1 kind: VolumeSnapshotClass metadata: name: csi-cinder-snapclass -snapshotter: cinder.csi.openstack.org +driver: cinder.csi.openstack.org +deletionPolicy: Delete --- diff --git a/examples/cinder-csi-plugin/snapshot/snapshotcreate.yaml b/examples/cinder-csi-plugin/snapshot/snapshotcreate.yaml index 42b7dcd917..4c98ab9625 100644 --- a/examples/cinder-csi-plugin/snapshot/snapshotcreate.yaml +++ b/examples/cinder-csi-plugin/snapshot/snapshotcreate.yaml @@ -1,9 +1,8 @@ -apiVersion: snapshot.storage.k8s.io/v1alpha1 +apiVersion: snapshot.storage.k8s.io/v1beta1 kind: VolumeSnapshot metadata: name: new-snapshot-demo spec: - snapshotClassName: csi-cinder-snapclass + volumeSnapshotClassName: csi-cinder-snapclass source: - name: pvc-snapshot-demo - kind: PersistentVolumeClaim + persistentVolumeClaimName: pvc-snapshot-demo diff --git a/manifests/cinder-csi-plugin/cinder-csi-controllerplugin-rbac.yaml b/manifests/cinder-csi-plugin/cinder-csi-controllerplugin-rbac.yaml index d39b6251f8..67c2a17cdc 100644 --- a/manifests/cinder-csi-plugin/cinder-csi-controllerplugin-rbac.yaml +++ b/manifests/cinder-csi-plugin/cinder-csi-controllerplugin-rbac.yaml @@ -122,6 +122,9 @@ rules: - apiGroups: ["snapshot.storage.k8s.io"] resources: ["volumesnapshots/status"] verbs: ["update"] + - apiGroups: ["snapshot.storage.k8s.io"] + resources: ["volumesnapshotcontents/status"] + verbs: ["update"] - apiGroups: ["apiextensions.k8s.io"] resources: ["customresourcedefinitions"] verbs: ["create", "list", "watch", "delete"] diff --git a/manifests/cinder-csi-plugin/cinder-csi-controllerplugin.yaml b/manifests/cinder-csi-plugin/cinder-csi-controllerplugin.yaml index 2d9e443009..1114180542 100644 --- a/manifests/cinder-csi-plugin/cinder-csi-controllerplugin.yaml +++ b/manifests/cinder-csi-plugin/cinder-csi-controllerplugin.yaml @@ -58,13 +58,8 @@ spec: volumeMounts: - name: socket-dir mountPath: /var/lib/csi/sockets/pluginproxy/ - - name: csi-snapshotter - image: quay.io/k8scsi/csi-snapshotter:v1.2.2 - args: - - "--csi-address=$(ADDRESS)" - env: - - name: ADDRESS - value: /var/lib/csi/sockets/pluginproxy/csi.sock + - name: csi-snapshot-controller + image: quay.io/k8scsi/snapshot-controller:v2.0.1 imagePullPolicy: Always volumeMounts: - mountPath: /var/lib/csi/sockets/pluginproxy/ diff --git a/manifests/cinder-csi-plugin/cinder-csi-nodeplugin-rbac.yaml b/manifests/cinder-csi-plugin/cinder-csi-nodeplugin-rbac.yaml index 912923fcad..db589636d1 100644 --- a/manifests/cinder-csi-plugin/cinder-csi-nodeplugin-rbac.yaml +++ b/manifests/cinder-csi-plugin/cinder-csi-nodeplugin-rbac.yaml @@ -14,7 +14,15 @@ rules: - apiGroups: [""] resources: ["events"] verbs: ["get", "list", "watch", "create", "update", "patch"] - + - apiGroups: ["snapshot.storage.k8s.io"] + resources: ["volumesnapshotclasses"] + verbs: ["get", "list", "watch"] + - apiGroups: ["snapshot.storage.k8s.io"] + resources: ["volumesnapshotcontents"] + verbs: ["get", "list", "watch"] + - apiGroups: ["snapshot.storage.k8s.io"] + resources: ["volumesnapshotcontents/status"] + verbs: ["update"] --- kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 diff --git a/manifests/cinder-csi-plugin/cinder-csi-nodeplugin.yaml b/manifests/cinder-csi-plugin/cinder-csi-nodeplugin.yaml index 79a14af326..c5cf1673c9 100644 --- a/manifests/cinder-csi-plugin/cinder-csi-nodeplugin.yaml +++ b/manifests/cinder-csi-plugin/cinder-csi-nodeplugin.yaml @@ -42,6 +42,17 @@ spec: mountPath: /csi - name: registration-dir mountPath: /registration + - name: csi-snapshotter + image: quay.io/k8scsi/csi-snapshotter:v2.0.1 + args: + - "--csi-address=$(ADDRESS)" + env: + - name: ADDRESS + value: /var/lib/csi/sockets/pluginproxy/csi.sock + imagePullPolicy: Always + volumeMounts: + - mountPath: /var/lib/csi/sockets/pluginproxy/ + name: socket-dir - name: cinder-csi-plugin securityContext: privileged: true