From 2792dd239105625a28bb3efe8a10aac5dc930e48 Mon Sep 17 00:00:00 2001 From: zhouenhua Date: Fri, 12 Nov 2021 17:29:39 +0800 Subject: [PATCH] chorei&docs: optim Makefile and README 1. add container image build in Makefile 2. reorganized test guide 3. renamed csi-driver yaml. Signed-off-by: zhouenhua --- Makefile | 33 +++++++++++++-- README.md | 41 ++++++++++++------- cmd/nvmfplugin/{main.go => nvmfplugin.go} | 2 +- ...-nvme-driver.yaml => csi-nvmf-driver.yaml} | 0 ...{csi-nvme-node.yaml => csi-nvmf-node.yaml} | 0 5 files changed, 56 insertions(+), 20 deletions(-) rename cmd/nvmfplugin/{main.go => nvmfplugin.go} (99%) rename deploy/kubernetes/{csi-nvme-driver.yaml => csi-nvmf-driver.yaml} (100%) rename deploy/kubernetes/{csi-nvme-node.yaml => csi-nvmf-node.yaml} (100%) diff --git a/Makefile b/Makefile index 594481f..a0f3494 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,30 @@ -all: - REV=$(shell git describe --long --tags --match='v*' --dirty 2>/dev/null || git rev-list -n1 HEAD) - mkdir -p output - CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-X main.version=$(REV) -extldflags "-static"' -o ./output/$* ./cmd/nvmfplugin/$* +# Copyright 2021 The Kubernetes Authors. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License 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. + +CMDS=nvmfplugin +REV=$(shell git describe --long --tags --match='v*' --dirty 2>/dev/null || git rev-list -n1 HEAD) + +all: build + +build-%: + mkdir -p output + CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-X main.version=$(REV) -extldflags "-static"' -o ./output/$* ./cmd/nvmfplugin/$*.go + +container-%: build-% + docker build -t $*:latest -f Dockerfile --label revision=$(REV) . + +build: ${CMDS:%=build-%} +container: ${CMDS:%=container-%} +clean: + -rm -rf output/ diff --git a/README.md b/README.md index 08791af..e6dd774 100644 --- a/README.md +++ b/README.md @@ -22,24 +22,29 @@ $ modprobe nvme-tcp $ modprobe nvme-rdma ``` -## Start NVMf driver - -``` -$ ./output/nvmfplugin --endpoint tcp://127.0.0.1:10000 --nodeid CSINode -``` - ## Test NVMf driver using csc Get csc tool from https://github.com/rexray/gocsi/tree/master/csc ``` $ go get github.com/rexray/gocsi/csc ``` -### Get plugin info +### 1. Complile NVMf driver +``` +$ make +``` + +### 2. Start NVMf driver + +``` +$ ./output/nvmfplugin --endpoint tcp://127.0.0.1:10000 --nodeid CSINode +``` + +### 3.1 Get plugin info ``` $ csc identity plugin-info --endpoint tcp://127.0.0.1:10000 "csi.nvmf.com" "v1.0.0" ``` -### NodePublish a volume +### 3.2 NodePublish a volume ``` $ export TargetTrAddr="NVMf Target Server IP (Ex: 192.168.122.18)" $ export TargetTrPort="NVMf Target Server Ip Port (Ex: 49153)" @@ -53,25 +58,31 @@ nvmftestvol ``` You can find a new disk on /mnt/nvmf -### NodeUnpublish a volume +### 3.3 NodeUnpublish a volume ``` $ csc node unpublish --endpoint tcp://127.0.0.1:10000 --target-path /mnt/nvmf nvmftestvol nvmftestvol ``` ## Test NVMf driver in kubernetes cluster -- TODO: because remote disk creation requires a controller. +> TODO: support dynamic provision. -### Installation +### 1. Docker Build image +``` +$ make container +``` + +### 2.1 Load Driver ``` $ kubectl create -f deploy/kubernetes/ ``` -### Uninstallation +### 2.2 Unload Driver ``` $ kubectl delete -f deploy/kubenetes/ ``` -### Create Storage Class +### 3.1 Create Storage Class(Dynamic Provisioning) +> NotSupport for controller not ready - Create ``` $ kubectl create -f examples/kubernetes/example/storageclass.yaml @@ -81,7 +92,7 @@ $ kubectl create -f examples/kubernetes/example/storageclass.yaml $ kubectl get sc ``` -### Create PV +### 3.2 Create PV(Static Provisioning) - Create ``` $ kubectl create -f examples/kubernetes/example/pv.yaml @@ -90,7 +101,7 @@ $ kubectl create -f examples/kubernetes/example/pv.yaml ``` $ kubectl get pv ``` -### Mount Volume +### 4. Create Nginx Container - Create Deployment ``` $ kubectl create -f examples/kubernetes/example/nginx.yaml diff --git a/cmd/nvmfplugin/main.go b/cmd/nvmfplugin/nvmfplugin.go similarity index 99% rename from cmd/nvmfplugin/main.go rename to cmd/nvmfplugin/nvmfplugin.go index 62df685..046da8b 100644 --- a/cmd/nvmfplugin/main.go +++ b/cmd/nvmfplugin/nvmfplugin.go @@ -48,7 +48,7 @@ func main() { flag.Parse() flag.CommandLine.Parse([]string{}) cmd := &cobra.Command{ - Use:"NVMf", + Use: "NVMf", Short: "CSI based NVMf driver", Run: func(cmd *cobra.Command, args []string) { handle() diff --git a/deploy/kubernetes/csi-nvme-driver.yaml b/deploy/kubernetes/csi-nvmf-driver.yaml similarity index 100% rename from deploy/kubernetes/csi-nvme-driver.yaml rename to deploy/kubernetes/csi-nvmf-driver.yaml diff --git a/deploy/kubernetes/csi-nvme-node.yaml b/deploy/kubernetes/csi-nvmf-node.yaml similarity index 100% rename from deploy/kubernetes/csi-nvme-node.yaml rename to deploy/kubernetes/csi-nvmf-node.yaml