Skip to content

Commit

Permalink
Merge pull request #35 from civo/feat/introduce-external-snapshotter
Browse files Browse the repository at this point in the history
Introduce external snapshotter and snapshot controller for VolumeSnapshot support
  • Loading branch information
hlts2 authored Dec 4, 2024
2 parents 1eaa5d6 + c2151b8 commit 5c71fef
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 2 deletions.
55 changes: 54 additions & 1 deletion deploy/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,46 @@ roleRef:
name: external-resizer-runner
apiGroup: rbac.authorization.k8s.io
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: external-snapshotter-runner
rules:
- apiGroups: [""]
resources: ["events"]
verbs: ["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", "update", "patch"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotcontents/status"]
verbs: ["update", "patch"]
- apiGroups: ["groupsnapshot.storage.k8s.io"]
resources: ["volumegroupsnapshotclasses"]
verbs: ["get", "list", "watch"]
- apiGroups: ["groupsnapshot.storage.k8s.io"]
resources: ["volumegroupsnapshotcontents"]
verbs: ["get", "list", "watch", "update", "patch"]
- apiGroups: ["groupsnapshot.storage.k8s.io"]
resources: ["volumegroupsnapshotcontents/status"]
verbs: ["update", "patch"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-snapshotter-role
subjects:
- kind: ServiceAccount
name: civo-csi-controller-sa
namespace: kube-system
roleRef:
kind: ClusterRole
name: external-snapshotter-runner
apiGroup: rbac.authorization.k8s.io
---
apiVersion: storage.k8s.io/v1
kind: CSIDriver
metadata:
Expand Down Expand Up @@ -225,7 +265,7 @@ spec:
- name: socket-dir
mountPath: /var/lib/kubelet/plugins/csi.civo.com
- name: csi-resizer
image: k8s.gcr.io/sig-storage/csi-resizer:v1.4.0
image: k8s.gcr.io/sig-storage/csi-resizer:v1.4.0
args:
- "--v=5"
- "--csi-address=$(ADDRESS)"
Expand All @@ -237,6 +277,19 @@ spec:
volumeMounts:
- name: socket-dir
mountPath: /var/lib/kubelet/plugins/csi.civo.com
- name: csi-snapshotter
image: k8s.gcr.io/sig-storage/csi-snapshotter:v8.1.0
args:
- "--v=5"
- "--csi-address=$(ADDRESS)"
- "--timeout=30s"
env:
- name: ADDRESS
value: /var/lib/kubelet/plugins/csi.civo.com/csi.sock
imagePullPolicy: "IfNotPresent"
volumeMounts:
- name: socket-dir
mountPath: /var/lib/kubelet/plugins/csi.civo.com
- name: civo-csi-plugin
image: gcr.io/consummate-yew-302509/csi:latest
env:
Expand Down
40 changes: 40 additions & 0 deletions deploy/kubernetes/01_rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,43 @@ roleRef:
kind: ClusterRole
name: external-resizer-runner
apiGroup: rbac.authorization.k8s.io
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: external-snapshotter-runner
rules:
- apiGroups: [""]
resources: ["events"]
verbs: ["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", "update", "patch"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotcontents/status"]
verbs: ["update", "patch"]
- apiGroups: ["groupsnapshot.storage.k8s.io"]
resources: ["volumegroupsnapshotclasses"]
verbs: ["get", "list", "watch"]
- apiGroups: ["groupsnapshot.storage.k8s.io"]
resources: ["volumegroupsnapshotcontents"]
verbs: ["get", "list", "watch", "update", "patch"]
- apiGroups: ["groupsnapshot.storage.k8s.io"]
resources: ["volumegroupsnapshotcontents/status"]
verbs: ["update", "patch"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: csi-snapshotter-role
subjects:
- kind: ServiceAccount
name: civo-csi-controller-sa
namespace: kube-system
roleRef:
kind: ClusterRole
name: external-snapshotter-runner
apiGroup: rbac.authorization.k8s.io
15 changes: 14 additions & 1 deletion deploy/kubernetes/04_controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ spec:
- name: socket-dir
mountPath: /var/lib/kubelet/plugins/csi.civo.com
- name: csi-resizer
image: k8s.gcr.io/sig-storage/csi-resizer:v1.4.0
image: k8s.gcr.io/sig-storage/csi-resizer:v1.4.0
args:
- "--v=5"
- "--csi-address=$(ADDRESS)"
Expand All @@ -70,6 +70,19 @@ spec:
volumeMounts:
- name: socket-dir
mountPath: /var/lib/kubelet/plugins/csi.civo.com
- name: csi-snapshotter
image: k8s.gcr.io/sig-storage/csi-snapshotter:v8.1.0
args:
- "--v=5"
- "--csi-address=$(ADDRESS)"
- "--timeout=30s"
env:
- name: ADDRESS
value: /var/lib/kubelet/plugins/csi.civo.com/csi.sock
imagePullPolicy: "IfNotPresent"
volumeMounts:
- name: socket-dir
mountPath: /var/lib/kubelet/plugins/csi.civo.com
- name: civo-csi-plugin
image: gcr.io/consummate-yew-302509/csi:latest
env:
Expand Down
11 changes: 11 additions & 0 deletions deploy/kubernetes/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- snapshot-controller

# For CSI driver
- 01_rbac.yaml
- 02_csi_driver.yaml
- 03_storage_class.yaml
- 04_controller.yaml
- 05_node.yaml
19 changes: 19 additions & 0 deletions deploy/kubernetes/snapshot-controller/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
# For CRD
- https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/release-8.1/client/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml
- https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/release-8.1/client/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml
- https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/release-8.1/client/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml

## For snapshot-controller
- https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/v8.0.1/deploy/kubernetes/snapshot-controller/setup-snapshot-controller.yaml
- https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/v8.0.1/deploy/kubernetes/snapshot-controller/rbac-snapshot-controller.yaml

# For VolumeSnapshotClass
- volume_snapshot_class.yaml

images:
- name: registry.k8s.io/sig-storage/snapshot-controller:v7.0.1
newName: k8s.gcr.io/sig-storage/snapshot-controller
newTag: v8.0.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotClass
metadata:
name: civo-volume-snapshot
driver: csi.civo.com
deletionPolicy: Delete

0 comments on commit 5c71fef

Please sign in to comment.