mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-22 21:10:22 +00:00
Merge pull request #118 from mickymiek/add-snapshotter-yamls
Added snapshotter deployments files + instuctions to deploy
This commit is contained in:
commit
87dd3622fb
@ -15,3 +15,32 @@ $ kubectl create -f pod.yaml
|
||||
Other helper scripts:
|
||||
* `logs.sh` output of the plugin
|
||||
* `exec-bash.sh` logs into the plugin's container and runs bash
|
||||
|
||||
|
||||
## How to test RBD Snapshot feature
|
||||
|
||||
Before continuing, make sure you enabled the required [feature gate](https://kubernetes-csi.github.io/docs/Setup.html#csi-volume-snapshot-support) in your Kubernetes cluster.
|
||||
|
||||
In the `examples/rbd` directory you will find four files related to snapshots: [csi-snapshotter-rbac.yaml](./rbd/csi-snapshotter-rbac.yaml), [csi-snapshotter.yaml](./rbd/csi-snapshotter.yaml), [snapshotclass.yaml](./rbd/snapshotclass.yaml) and [snapshot.yaml](./rbd/snapshot.yaml).
|
||||
|
||||
Once you created your RBD volume, you'll need to customize at least `snapshotclass.yaml` and make sure the `monitors` and `pool` parameters match your Ceph cluster setup. If you followed the documentation to create the rbdplugin, you shouldn't have to edit any other file. If you didn't, make sure every parameters in `csi-snapshotter.yaml` reflect your configuration.
|
||||
|
||||
After configuring everything you needed, deploy the csi-snapshotter:
|
||||
```bash
|
||||
$ kubectl create -f csi-snapshotter-rbac.yaml
|
||||
$ kubectl create -f csi-snapshotter.yaml
|
||||
$ kubectl create -f snapshotclass.yaml
|
||||
$ kubectl create -f snapshot.yaml
|
||||
```
|
||||
|
||||
To verify if your volume snapshot has successfully been created, run the following:
|
||||
```bash
|
||||
$ kubectl get volumesnapshotclass
|
||||
NAME AGE
|
||||
csi-rbdplugin-snapclass 4s
|
||||
$ kubectl get volumesnapshot
|
||||
NAME AGE
|
||||
rbd-pvc-snapshot 6s
|
||||
```
|
||||
|
||||
To be sure everything is OK you can run `rbd snap ls [your-pvc-name]` inside one of your Ceph pod.
|
||||
|
45
examples/rbd/csi-snapshotter-rbac.yaml
Normal file
45
examples/rbd/csi-snapshotter-rbac.yaml
Normal file
@ -0,0 +1,45 @@
|
||||
kind: ClusterRole
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: external-snapshotter-runner
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["persistentvolumes"]
|
||||
verbs: ["get", "list", "watch", "create", "delete"]
|
||||
- apiGroups: [""]
|
||||
resources: ["persistentvolumeclaims"]
|
||||
verbs: ["get", "list", "watch", "update"]
|
||||
- apiGroups: ["storage.k8s.io"]
|
||||
resources: ["storageclasses"]
|
||||
verbs: ["get", "list", "watch"]
|
||||
- apiGroups: [""]
|
||||
resources: ["events"]
|
||||
verbs: ["list", "watch", "create", "update", "patch"]
|
||||
- apiGroups: [""]
|
||||
resources: ["secrets"]
|
||||
verbs: ["get", "list"]
|
||||
- apiGroups: ["snapshot.storage.k8s.io"]
|
||||
resources: ["volumesnapshotclasses"]
|
||||
verbs: ["get", "list", "watch"]
|
||||
- apiGroups: ["snapshot.storage.k8s.io"]
|
||||
resources: ["volumesnapshotcontents"]
|
||||
verbs: ["create", "get", "list", "watch", "update", "delete"]
|
||||
- apiGroups: ["snapshot.storage.k8s.io"]
|
||||
resources: ["volumesnapshots"]
|
||||
verbs: ["get", "list", "watch", "update"]
|
||||
- apiGroups: ["apiextensions.k8s.io"]
|
||||
resources: ["customresourcedefinitions"]
|
||||
verbs: ["create"]
|
||||
---
|
||||
kind: ClusterRoleBinding
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: csi-snapshotter-role
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: csi-snapshotter
|
||||
namespace: default
|
||||
roleRef:
|
||||
kind: ClusterRole
|
||||
name: external-snapshotter-runner
|
||||
apiGroup: rbac.authorization.k8s.io
|
56
examples/rbd/csi-snapshotter.yaml
Normal file
56
examples/rbd/csi-snapshotter.yaml
Normal file
@ -0,0 +1,56 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: csi-snapshotter
|
||||
---
|
||||
kind: Service
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: csi-snapshotter
|
||||
labels:
|
||||
app: csi-snapshotter
|
||||
spec:
|
||||
selector:
|
||||
app: csi-snapshotter
|
||||
ports:
|
||||
- name: dummy
|
||||
port: 12345
|
||||
---
|
||||
kind: StatefulSet
|
||||
apiVersion: apps/v1
|
||||
metadata:
|
||||
name: csi-snapshotter
|
||||
spec:
|
||||
serviceName: "csi-snapshotter"
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: csi-snapshotter
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: csi-snapshotter
|
||||
spec:
|
||||
serviceAccount: csi-snapshotter
|
||||
containers:
|
||||
- name: csi-snapshotter
|
||||
image: quay.io/k8scsi/csi-snapshotter:v0.4.0
|
||||
args:
|
||||
- "--csi-address=$(ADDRESS)"
|
||||
- "--connection-timeout=15s"
|
||||
- "--v=5"
|
||||
env:
|
||||
- name: ADDRESS
|
||||
value: /csi/csi.sock
|
||||
imagePullPolicy: Always
|
||||
securityContext:
|
||||
privileged: true
|
||||
volumeMounts:
|
||||
- name: socket-dir
|
||||
mountPath: /csi
|
||||
imagePullPolicy: Always
|
||||
volumes:
|
||||
- hostPath:
|
||||
path: /var/lib/kubelet/plugins/csi-rbdplugin
|
||||
type: DirectoryOrCreate
|
||||
name: socket-dir
|
9
examples/rbd/snapshot.yaml
Normal file
9
examples/rbd/snapshot.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
apiVersion: snapshot.storage.k8s.io/v1alpha1
|
||||
kind: VolumeSnapshot
|
||||
metadata:
|
||||
name: rbd-pvc-snapshot
|
||||
spec:
|
||||
snapshotClassName: csi-rbdplugin-snapclass
|
||||
source:
|
||||
name: rbd-pvc
|
||||
kind: PersistentVolumeClaim
|
10
examples/rbd/snapshotclass.yaml
Normal file
10
examples/rbd/snapshotclass.yaml
Normal file
@ -0,0 +1,10 @@
|
||||
apiVersion: snapshot.storage.k8s.io/v1alpha1
|
||||
kind: VolumeSnapshotClass
|
||||
metadata:
|
||||
name: csi-rbdplugin-snapclass
|
||||
snapshotter: csi-rbdplugin
|
||||
parameters:
|
||||
pool: rbd
|
||||
monitors: mon1:port,mon2:port,...
|
||||
csiSnapshotterSecretName: csi-rbd-secret
|
||||
csiSnapshotterSecretNamespace: default
|
Loading…
Reference in New Issue
Block a user