Skip to content

Commit

Permalink
Merge pull request #72 from wnxn/create-delete-snapshot
Browse files Browse the repository at this point in the history
add create and delete snapshot
  • Loading branch information
Wiley Wang authored Jul 3, 2019
2 parents e85c5fe + d2d068a commit 3b5a2be
Show file tree
Hide file tree
Showing 26 changed files with 1,009 additions and 51 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ disk-container: disk
docker build -t $(DISK_IMAGE_NAME):$(DISK_IMAGE_VERSION) deploy/disk/docker

install-dev:
cp /root/.qingcloud/config.yaml deploy/disk/kubernetes/base/config.yaml
kustomize build deploy/disk/kubernetes/overlays/dev|kubectl apply -f -

uninstall-dev:
kustomize build deploy/disk/kubernetes/overlays/dev|kubectl delete -f -

gen-dev:
cp /root/.qingcloud/config.yaml deploy/disk/kubernetes/base/config.yaml
kustomize build deploy/disk/kubernetes/overlays/dev

install-prod:
Expand Down
44 changes: 44 additions & 0 deletions deploy/disk/example/snapshot/deploy-viewer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# +-------------------------------------------------------------------------
# | Copyright (C) 2018 Yunify, Inc.
# +-------------------------------------------------------------------------
# | Licensed under the Apache License, Version 2.0 (the "License");
# | you may not use this work except in compliance with the License.
# | You may obtain a copy of the License in the LICENSE file, or at:
# |
# | http://www.apache.org/licenses/LICENSE-2.0
# |
# | Unless required by applicable law or agreed to in writing, software
# | distributed under the License is distributed on an "AS IS" BASIS,
# | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# | See the License for the specific language governing permissions and
# | limitations under the License.
# +-------------------------------------------------------------------------

apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
selector:
matchLabels:
app: nginx
tier: csi-qingcloud
replicas: 1
template:
metadata:
labels:
app: nginx
tier: csi-qingcloud
spec:
containers:
- name: nginx
image: nginx
volumeMounts:
- mountPath: /mnt
name: mypvc
volumes:
- name: mypvc
persistentVolumeClaim:
claimName: restore-from-snap
readOnly: false

46 changes: 46 additions & 0 deletions deploy/disk/example/snapshot/deploy-writer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# +-------------------------------------------------------------------------
# | Copyright (C) 2018 Yunify, Inc.
# +-------------------------------------------------------------------------
# | Licensed under the Apache License, Version 2.0 (the "License");
# | you may not use this work except in compliance with the License.
# | You may obtain a copy of the License in the LICENSE file, or at:
# |
# | http://www.apache.org/licenses/LICENSE-2.0
# |
# | Unless required by applicable law or agreed to in writing, software
# | distributed under the License is distributed on an "AS IS" BASIS,
# | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# | See the License for the specific language governing permissions and
# | limitations under the License.
# +-------------------------------------------------------------------------

apiVersion: apps/v1
kind: Deployment
metadata:
name: fio
spec:
selector:
matchLabels:
app: fio
tier: csi-qingcloud
replicas: 1
template:
metadata:
labels:
app: fio
tier: csi-qingcloud
spec:
imagePullSecrets:
- name: csi-qingcloud
containers:
- name: fio
image: dockerhub.qingcloud.com/csiplugin/fio-test:latest
volumeMounts:
- mountPath: /mnt
name: mypvc
volumes:
- name: mypvc
persistentVolumeClaim:
claimName: pvc-for-snap
readOnly: false

23 changes: 23 additions & 0 deletions deploy/disk/example/snapshot/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# +-------------------------------------------------------------------------
# | Copyright (C) 2018 Yunify, Inc.
# +-------------------------------------------------------------------------
# | Licensed under the Apache License, Version 2.0 (the "License");
# | you may not use this work except in compliance with the License.
# | You may obtain a copy of the License in the LICENSE file, or at:
# |
# | http://www.apache.org/licenses/LICENSE-2.0
# |
# | Unless required by applicable law or agreed to in writing, software
# | distributed under the License is distributed on an "AS IS" BASIS,
# | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# | See the License for the specific language governing permissions and
# | limitations under the License.
# +-------------------------------------------------------------------------


FROM nginx
LABEL maintainers="Yunify"
LABEL description="QingCloud CSI plugin"
RUN apt update && apt install vim fio -y
COPY test.fio start-test.sh /root/
RUN chmod +x /root/start-test.sh
27 changes: 27 additions & 0 deletions deploy/disk/example/snapshot/docker/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# +-------------------------------------------------------------------------
# | Copyright (C) 2018 Yunify, Inc.
# +-------------------------------------------------------------------------
# | Licensed under the Apache License, Version 2.0 (the "License");
# | you may not use this work except in compliance with the License.
# | You may obtain a copy of the License in the LICENSE file, or at:
# |
# | http://www.apache.org/licenses/LICENSE-2.0
# |
# | Unless required by applicable law or agreed to in writing, software
# | distributed under the License is distributed on an "AS IS" BASIS,
# | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# | See the License for the specific language governing permissions and
# | limitations under the License.
# +-------------------------------------------------------------------------

.PHONY: all image

IMAGE_REPO=dockerhub.qingcloud.com/csiplugin/
IMAGE_NAME=fio-test
IMAGE_TAG=latest

image:
docker build -t $(IMAGE_REPO)$(IMAGE_NAME):$(IMAGE_TAG) ./

clean:
docker rmi $(IMAGE_REPO)$(IMAGE_NAME):$(IMAGE_TAG)
2 changes: 2 additions & 0 deletions deploy/disk/example/snapshot/docker/start-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# !/bin/sh
fio /root/test.fio -directory /mnt -output /root/test.result
32 changes: 32 additions & 0 deletions deploy/disk/example/snapshot/docker/test.fio
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[global]
bs=4k
ioengine=libaio
iodepth=16
size=10g
direct=1
runtime=60
numjobs=4

[seq-read]
rw=read
stonewall

[rand-read]
rw=randread
stonewall

[seq-write]
rw=write
stonewall

[rand-write]
rw=randwrite
stonewall

[seq-rw]
rw=rw
stonewall

[rand-rw]
rw=randrw
stonewall
27 changes: 27 additions & 0 deletions deploy/disk/example/snapshot/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# +-------------------------------------------------------------------------
# | Copyright (C) 2018 Yunify, Inc.
# +-------------------------------------------------------------------------
# | Licensed under the Apache License, Version 2.0 (the "License");
# | you may not use this work except in compliance with the License.
# | You may obtain a copy of the License in the LICENSE file, or at:
# |
# | http://www.apache.org/licenses/LICENSE-2.0
# |
# | Unless required by applicable law or agreed to in writing, software
# | distributed under the License is distributed on an "AS IS" BASIS,
# | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# | See the License for the specific language governing permissions and
# | limitations under the License.
# +-------------------------------------------------------------------------

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-for-snap
spec:
storageClassName: csi-qingcloud
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
31 changes: 31 additions & 0 deletions deploy/disk/example/snapshot/restore-pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# +-------------------------------------------------------------------------
# | Copyright (C) 2018 Yunify, Inc.
# +-------------------------------------------------------------------------
# | Licensed under the Apache License, Version 2.0 (the "License");
# | you may not use this work except in compliance with the License.
# | You may obtain a copy of the License in the LICENSE file, or at:
# |
# | http://www.apache.org/licenses/LICENSE-2.0
# |
# | Unless required by applicable law or agreed to in writing, software
# | distributed under the License is distributed on an "AS IS" BASIS,
# | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# | See the License for the specific language governing permissions and
# | limitations under the License.
# +-------------------------------------------------------------------------

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: restore-from-snap
spec:
storageClassName: csi-qingcloud
dataSource:
name: pvc-for-snap
kind: VolumeSnapshot
apiGroup: snapshot.storage.k8s.io
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
21 changes: 21 additions & 0 deletions deploy/disk/example/snapshot/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (C) 2018 Yunify, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this work except in compliance with the License.
# You may obtain a copy of the License in the LICENSE file, or at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: Secret
metadata:
name: csi-qingcloud
data:
.dockerconfigjson: eyJhdXRocyI6eyJkb2NrZXJodWIucWluZ2Nsb3VkLmNvbSI6eyJhdXRoIjoiWjNWbGMzUTZaM1ZsYzNRPSJ9fX0=
type: kubernetes.io/dockerconfigjson
21 changes: 21 additions & 0 deletions deploy/disk/example/snapshot/snapshot-class.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# +-------------------------------------------------------------------------
# | Copyright (C) 2018 Yunify, Inc.
# +-------------------------------------------------------------------------
# | Licensed under the Apache License, Version 2.0 (the "License");
# | you may not use this work except in compliance with the License.
# | You may obtain a copy of the License in the LICENSE file, or at:
# |
# | http://www.apache.org/licenses/LICENSE-2.0
# |
# | Unless required by applicable law or agreed to in writing, software
# | distributed under the License is distributed on an "AS IS" BASIS,
# | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# | See the License for the specific language governing permissions and
# | limitations under the License.
# +-------------------------------------------------------------------------

apiVersion: snapshot.storage.k8s.io/v1alpha1
kind: VolumeSnapshotClass
metadata:
name: csi-qingcloud
snapshotter: disk.csi.qingcloud.com
25 changes: 25 additions & 0 deletions deploy/disk/example/snapshot/volume-snapshot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# +-------------------------------------------------------------------------
# | Copyright (C) 2018 Yunify, Inc.
# +-------------------------------------------------------------------------
# | Licensed under the Apache License, Version 2.0 (the "License");
# | you may not use this work except in compliance with the License.
# | You may obtain a copy of the License in the LICENSE file, or at:
# |
# | http://www.apache.org/licenses/LICENSE-2.0
# |
# | Unless required by applicable law or agreed to in writing, software
# | distributed under the License is distributed on an "AS IS" BASIS,
# | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# | See the License for the specific language governing permissions and
# | limitations under the License.
# +-------------------------------------------------------------------------

apiVersion: snapshot.storage.k8s.io/v1alpha1
kind: VolumeSnapshot
metadata:
name: snap-test
spec:
snapshotClassName: csi-qingcloud
source:
name: pvc-for-snap
kind: PersistentVolumeClaim
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ spec:
- ReadWriteOnce
resources:
requests:
storage: 345Gi
storage: 20Gi
storageClassName: csi-qingcloud
File renamed without changes.
2 changes: 1 addition & 1 deletion deploy/disk/kubernetes/base/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ port: 443
protocol: 'https'
uri: '/iaas'
connection_retries: 3
connection_timeout: 30
connection_timeout: 30
15 changes: 14 additions & 1 deletion deploy/disk/kubernetes/base/controller-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ spec:
- "--csi-address=$(ADDRESS)"
- "--enable-leader-election"
- "--leader-election-type=leases"
- "--timeout=60s"
- "--timeout=90s"
- "--retry-interval-start=5s"
- "--retry-interval-max=5m"
- "--worker-threads=5"
Expand Down Expand Up @@ -85,6 +85,19 @@ spec:
volumeMounts:
- name: socket-dir
mountPath: /csi
- name: csi-snapshotter
image: quay.io/k8scsi/csi-snapshotter:v1.2.0
args:
- "--csi-address=$(ADDRESS)"
- "--connection-timeout=90s"
- "--leader-election=false"
env:
- name: ADDRESS
value: /csi/csi.sock
imagePullPolicy: "IfNotPresent"
volumeMounts:
- name: socket-dir
mountPath: /csi
- name: csi-resizer
image: quay.io/k8scsi/csi-resizer:v0.1.0
args:
Expand Down
Loading

0 comments on commit 3b5a2be

Please sign in to comment.