Skip to content

Commit

Permalink
Merge pull request #44 from min-zh/block
Browse files Browse the repository at this point in the history
RWM & Block
  • Loading branch information
zheng1 authored Sep 21, 2020
2 parents 7405064 + 03d45a9 commit 5129dda
Show file tree
Hide file tree
Showing 1,049 changed files with 77,922 additions and 28,572 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
language: go
go:
- "1.12"
- "1.14"
services:
- docker
before_install:
- docker pull golang:1.12.7-alpine
- docker pull golang:1.14.4-alpine
- docker pull k8s.gcr.io/debian-base:v1.0.0
- docker tag k8s.gcr.io/debian-base:v1.0.0 gcr.azk8s.cn/google_containers/debian-base:v1.0.0

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
.PHONY: all disk

IMAGE=csiplugin/csi-neonsan
TAG=v1.2.0
TAG=canary
IMAGE_UBUNTU=csiplugin/csi-neonsan-ubuntu
TAG_UBUNTU=v1.2.0
TAG_UBUNTU=canary
IMAGE_CENTOS=csiplugin/csi-neonsan-centos
TAG_CENTOS=v1.2.0
TAG_CENTOS=canary
ROOT_PATH=$(pwd)
PACKAGE_LIST=./cmd/... ./pkg/...

Expand Down
6 changes: 1 addition & 5 deletions cmd/neonsan/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package main

import (
"flag"
"github.com/yunify/qingstor-csi/pkg/common"
"github.com/yunify/qingstor-csi/pkg/service"
"github.com/yunify/qingstor-csi/pkg/storage/neonsan"
"k8s.io/klog"
Expand Down Expand Up @@ -85,9 +84,6 @@ func handle() {
SetPluginCapabilities(service.DefaultPluginCapability).
SetRetryTime(rt)

// Mounter
formatMounter := common.NewSafeMounter()

// service
service.Run(serviceOpt, storageProvider, formatMounter, *endpoint)
service.Run(serviceOpt, storageProvider, *endpoint)
}
2 changes: 1 addition & 1 deletion deploy/neonsan/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# | limitations under the License.
# +-------------------------------------------------------------------------

FROM golang:1.12.7-alpine as builder
FROM golang:1.14.4-alpine as builder
WORKDIR /qingstor-csi
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -a -mod=vendor -ldflags "-s -w" -o _output/neonsan-csi-driver ./cmd/neonsan
Expand Down
2 changes: 1 addition & 1 deletion deploy/neonsan/docker/centos/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# | limitations under the License.
# +-------------------------------------------------------------------------

FROM golang:1.12.7-alpine as builder
FROM golang:1.14.4-alpine as builder
WORKDIR /qingstor-csi
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -a -mod=vendor -ldflags "-s -w" -o _output/neonsan-csi-driver ./cmd/neonsan
Expand Down
2 changes: 1 addition & 1 deletion deploy/neonsan/docker/ubuntu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# | limitations under the License.
# +-------------------------------------------------------------------------

FROM golang:1.12.7-alpine as builder
FROM golang:1.14.4-alpine as builder
WORKDIR /qingstor-csi
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -a -mod=vendor -ldflags "-s -w" -o _output/neonsan-csi-driver ./cmd/neonsan
Expand Down
43 changes: 43 additions & 0 deletions deploy/neonsan/example/volume/deploy-nginx-block-1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# +-------------------------------------------------------------------------
# | 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-block-1
spec:
selector:
matchLabels:
app: nginx-block-1
replicas: 1
template:
metadata:
labels:
app: nginx-block-1
spec:
containers:
- name: nginx
image: nginx
volumeDevices:
- devicePath: /dev/xvda
name: mypvc
volumes:
- name: mypvc
persistentVolumeClaim:
claimName: pvc-block
readOnly: false


43 changes: 43 additions & 0 deletions deploy/neonsan/example/volume/deploy-nginx-block-2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# +-------------------------------------------------------------------------
# | 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-block-2
spec:
selector:
matchLabels:
app: nginx-block-2
replicas: 1
template:
metadata:
labels:
app: nginx-block-2
spec:
containers:
- name: nginx
image: nginx
volumeDevices:
- devicePath: /dev/xvda
name: mypvc
volumes:
- name: mypvc
persistentVolumeClaim:
claimName: pvc-block
readOnly: false


28 changes: 28 additions & 0 deletions deploy/neonsan/example/volume/pvc-block.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# +-------------------------------------------------------------------------
# | 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-block
spec:
accessModes:
- ReadWriteMany
volumeMode: Block
resources:
requests:
storage: 1Gi
storageClassName: csi-neonsan
58 changes: 54 additions & 4 deletions docs/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Set the annotation `.metadata.annotations.storageclass.beta.kubernetes.io/is-def
Set the value of `.allowVolumeExpansion` as `true`. See details in [Kubernetes docs](https://kubernetes.io/docs/concepts/storage/storage-classes/#allow-volume-expansion)

## Volume Management
Volume management including dynamical provisioning/deleting volume, attaching/detaching volume. Please reference [Example YAML Files](https://github.com/yunify/qingcloud-csi/tree/master/deploy/disk/example/volume).
Volume management including dynamical provisioning/deleting volume, attaching/detaching volume. Please reference [volume example](/deploy/neonsan/example/volume).

### Prerequisite
- Kubernetes 1.14+
Expand Down Expand Up @@ -107,7 +107,7 @@ This plugin only supports offline volume expansion. The procedure of offline vol
1. Ensure volume in unmounted status
2. Edit the capacity of PVC
3. Mount volume on workload
Please reference [Example YAML files](deploy/neonsan/example/volume).
Please reference [volume example](/deploy/neonsan/example/volume).

### Prerequisite
- Kubernetes 1.14+ cluster
Expand Down Expand Up @@ -151,7 +151,7 @@ Filesystem Size Used Avail Use% Mounted on
```

## Volume Cloning
Cloning is defined as a duplicate of an existing PVC. Please reference [Example YAML](deploy/neonsan/example/volume)
Cloning is defined as a duplicate of an existing PVC. Please reference [volume example](/deploy/neonsan/example/volume)

### Prerequisites
- Kubernetes 1.15+
Expand Down Expand Up @@ -183,7 +183,7 @@ pvc-clone Bound pvc-a75e3f7c-59af-43ef-82d3-300508871432 20Gi RWO
```

## Snapshot Management
Snapshot management contains creating/deleting snapshot and restoring volume from snapshot. Please reference [Example YAML files](deploy/neonsan/example/snapshot).
Snapshot management contains creating/deleting snapshot and restoring volume from snapshot. Please reference [snapshot examples](/deploy/neonsan/example/snapshot).

### Prerequisites
- Kubernetes 1.14+
Expand Down Expand Up @@ -245,3 +245,53 @@ pvc-snap Bound pvc-a56f6ebe-b37b-40d7-bfb7-aafbecb6672b 20Gi RWO
$ kubectl delete volumesnapshot snap-1
volumesnapshot.snapshot.storage.k8s.io "snap-1" deleted
```

## RWM Block Volume
Volume [Access Mode](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes) `ReadWriteMany` is only available
[VolumeMode](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#volume-mode) `Block` on NeonSAN-CSI.
Following are examples for `Block RWM` PVC. Please reference [volume examples](/deploy/neonsan/example/volume).

### Create PVC
```bash
kubectl apply -f pvc-block.yaml
persistentvolumeclaim/pvc-block created

kubectl get pvc pvc-block
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
pvc-block Bound pvc-d4e44291-c8e8-4a6d-9a4c-6a3662672d77 1Gi RWX csi-neonsan 9m57s

```

### Attach PVC for multi-pods
```bash
kubectl apply -f deploy-nginx-block-1.yaml
deployment.apps/nginx-block-1 created

kubectl apply -f deploy-nginx-block-2.yaml
deployment.apps/nginx-block-2 created

kubectl get pod
NAME READY STATUS RESTARTS AGE
nginx-block-1-65ddc6bf75-zdnqg 1/1 Running 0 8m40s
nginx-block-2-788bfbbf4b-b4kpd 1/1 Running 0 7m55s
```

### Check

Block device in container-1:
```bash
kubectl exec -it deployment/nginx-block-1 -- fdisk -l /dev/xvda
Disk /dev/xvda: 1 GiB, 1073741824 bytes, 2097152 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
```

Block device in container-2:
```bash
kubectl exec -it deployment/nginx-block-2 -- fdisk -l /dev/xvda
Disk /dev/xvda: 1 GiB, 1073741824 bytes, 2097152 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
```
55 changes: 35 additions & 20 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,48 @@ go 1.12
require (
bou.ke/monkey v1.0.1
github.com/container-storage-interface/spec v1.2.0
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 // indirect
github.com/golang/protobuf v1.3.2
github.com/googleapis/gnostic v0.3.0 // indirect
github.com/hashicorp/golang-lru v0.5.1 // indirect
github.com/kubernetes-csi/csi-lib-utils v0.2.0
github.com/kubernetes-csi/csi-test v2.2.0+incompatible
github.com/onsi/ginkgo v1.8.0
github.com/onsi/gomega v1.5.0
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
github.com/kubernetes-csi/csi-test/v3 v3.1.1
github.com/onsi/ginkgo v1.11.0
github.com/onsi/gomega v1.7.1
github.com/pelletier/go-toml v1.2.0
github.com/prometheus/client_golang v1.1.0 // indirect
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da
github.com/smartystreets/goconvey v1.6.4
github.com/stretchr/testify v1.4.0 // indirect
golang.org/x/net v0.0.0-20190812203447-cdfb69ac37fc
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 // indirect
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
golang.org/x/net v0.0.0-20191112182307-2180aed22343
google.golang.org/appengine v1.6.1 // indirect
google.golang.org/grpc v1.23.0
gopkg.in/inf.v0 v0.9.1 // indirect
k8s.io/apiextensions-apiserver v0.0.0-20190823014223-07b4561f8b0e // indirect
k8s.io/apimachinery v0.0.0-20190823012420-8ca64af22337
k8s.io/apiserver v0.0.0-20190823053033-1316076af51c // indirect
k8s.io/client-go v0.0.0-20190823012814-cdbd92c111cf
k8s.io/cloud-provider v0.0.0-20190717025205-585d8110a88f // indirect
k8s.io/klog v0.4.0
k8s.io/kube-openapi v0.0.0-20190718094010-3cf2ea392886 // indirect
k8s.io/kubernetes v1.14.1
google.golang.org/grpc v1.26.0
k8s.io/apimachinery v0.18.6
k8s.io/client-go v0.18.6
k8s.io/klog v1.0.0
k8s.io/kubernetes v1.18.6
k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89
)

replace (
google.golang.org/grpc => google.golang.org/grpc v1.26.0
k8s.io/api => k8s.io/api v0.18.6
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.18.6
k8s.io/apimachinery => k8s.io/apimachinery v0.18.6
k8s.io/apiserver => k8s.io/apiserver v0.18.6
k8s.io/cli-runtime => k8s.io/cli-runtime v0.18.6
k8s.io/client-go => k8s.io/client-go v0.18.6
k8s.io/cloud-provider => k8s.io/cloud-provider v0.18.6
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.18.6
k8s.io/code-generator => k8s.io/code-generator v0.18.6
k8s.io/component-base => k8s.io/component-base v0.18.6
k8s.io/cri-api => k8s.io/cri-api v0.18.6
k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.18.6
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.18.6
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.18.6
k8s.io/kube-proxy => k8s.io/kube-proxy v0.18.6
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.18.6
k8s.io/kubectl => k8s.io/kubectl v0.18.6
k8s.io/kubelet => k8s.io/kubelet v0.18.6
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.18.6
k8s.io/metrics => k8s.io/metrics v0.18.6
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.18.6
)
Loading

0 comments on commit 5129dda

Please sign in to comment.