-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch provides a Go-based CSI client and server capable of supporting additional storage platforms at runtime via Go plug-ins.
- Loading branch information
Showing
219 changed files
with
70,927 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
go_import_path: github.com/container-storage-interface/examples | ||
|
||
language: go | ||
|
||
go: | ||
- 1.8.x | ||
|
||
env: | ||
global: | ||
- CSI_ENDPOINT=tcp://127.0.0.1:4210 | ||
|
||
before_install: | ||
- curl -LO https://github.com/google/protobuf/releases/download/v3.3.0/protoc-3.3.0-linux-x86_64.zip | ||
- unzip protoc-3.3.0-linux-x86_64.zip | ||
- chmod +x bin/protoc | ||
- export PATH="$(pwd)/bin:$PATH" | ||
|
||
install: | ||
- go get -u github.com/golang/protobuf/proto | ||
- go get -u github.com/golang/protobuf/protoc-gen-go | ||
- go get -u google.golang.org/grpc | ||
- make -C gocsi goget | ||
|
||
script: | ||
- make -C gocsi build | ||
- make -C gocsi test | ||
|
||
after_failure: | ||
- if [ -e "gocsi/csd.log" ]; then cat gocsi/csd.log; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
# examples | ||
Reference plugin implementations | ||
# Container Storage Interface (CSI) Examples [![build status](https://travis-ci.org/container-storage-interface/examples.svg?branch=master)](https://travis-ci.org/container-storage-interface/examples) | ||
This project contains examples CSI examples. | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| [gocsi](./gocsi) | A Go-based CSI client and server capable of supporting additional storage platforms at runtime via Go plug-ins. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.build/ | ||
.DS_Store | ||
csd.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
SHELL := $(shell env which bash) | ||
|
||
all: build | ||
|
||
# load the go bits | ||
include go.mk | ||
|
||
# configure and load the csi protobuf generator | ||
CSI_PROTO_DIR := csi | ||
include csi.mk | ||
|
||
# the name of the program being built | ||
PROG := $(PKG_DIR_GO)/$(IMPORT_PATH).a | ||
|
||
# the target for building the gocsi library | ||
$(PROG):$(CSI_GOSRC) \ | ||
$(filter-out %_test.go,$(wildcard *.go)) \ | ||
| $(GOGET) $(PKG_DIR_GO) | ||
go install -pkgdir $(abspath $(PKG_DIR_GO)) | ||
@echo $@ | ||
|
||
# a list of sub-projects to make | ||
SUB_PROJS := $(subst /,,$(dir $(wildcard */Makefile))) | ||
|
||
# prints a list of the projects to make | ||
projs: | ||
@echo . $(SUB_PROJS) | ||
|
||
build: $(PROG) | ||
$(foreach d,$(SUB_PROJS),$(MAKE) -C $d $@;) | ||
|
||
clean: | ||
go clean -i | ||
$(foreach d,$(SUB_PROJS),$(MAKE) -C $d $@;) | ||
|
||
clobber: clean | ||
rm -fr $(CSI_PROTO_DIR) $(BUILD_DIR) | ||
$(foreach d,$(SUB_PROJS),$(MAKE) -C $d $@;) | ||
|
||
goget: $(GOGET) | ||
$(foreach d,$(SUB_PROJS),$(MAKE) -C $d $@;) | ||
|
||
test: build | ||
CSI_PLUGINS=$$(pwd)/mod/moc/moc-csi-plugin.so csd/csd mock > csd.log 2>&1 & | ||
sleep 2s | ||
csc/csc ls | ||
csc/csc new -o norootsquash,uid=500,gid=500 \ | ||
-t ext4 -requiredBytes 107374182400 \ | ||
-params color=purple,up=down \ | ||
"My New Volume" | ||
csc/csc ls | ||
kill $$(ps aux | grep '[c]sd' | awk '{print $$2}') | ||
cat csd.log | ||
|
||
benchmark: $(PROG) | ||
go test -benchmem -parallel 100 -bench . | ||
|
||
.PHONY: projs build clean clobber goget test benchmark |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# gocsi | ||
This project provides a Go-based CSI client and server capable of | ||
supporting additional storage platforms at runtime via Go plug-ins. | ||
|
||
```bash | ||
# get and install the sources | ||
$ go get github.com/container-storage-interface/examples/gocsi | ||
|
||
# build the client | ||
$ go install github.com/container-storage-interface/examples/gocsi/csc | ||
|
||
# build the server | ||
$ go install github.com/container-storage-interface/examples/gocsi/csd | ||
|
||
# build the mock server plug-in | ||
$ go build -o mock.so -buildmode plugin github.com/container-storage-interface/examples/gocsi/mod/moc | ||
|
||
# export the CSI endpoint | ||
$ export CSI_ENDPOINT=tcp://127.0.0.0:8080 | ||
|
||
# start the server (assuming $GOPATH/bin is in the PATH) | ||
$ CSI_PLUGINS=$(pwd)/mock.so csd mock > csd.log 2>&1 & | ||
[1] 19050 | ||
|
||
# use the client to ask for a list of volumes | ||
$ csc ls | ||
id=1 name=Mock Volume 1 | ||
id=2 name=Mock Volume 2 | ||
id=3 name=Mock Volume 3 | ||
|
||
# create a new volume | ||
$ csc new "My New Volume" | ||
id=4 name=My New Volume | ||
|
||
# query the volume list again | ||
$ csc ls | ||
id=1 name=Mock Volume 1 | ||
id=2 name=Mock Volume 2 | ||
id=3 name=Mock Volume 3 | ||
id=4 name=My New Volume | ||
|
||
# kill the server | ||
kill -HUP %1 | ||
|
||
# view the server log | ||
$ cat csd.log | ||
2017/06/26 01:54:48 loaded plug-in: mock.so | ||
2017/06/26 01:54:48 registered endpoint: mock | ||
2017/06/26 01:54:48 mock.Serve | ||
2017/06/26 01:55:36 csd.ListVolumes | ||
2017/06/26 01:55:36 ...Volume.ID=1 | ||
2017/06/26 01:55:36 ...Volume.ID=2 | ||
2017/06/26 01:55:36 ...Volume.ID=3 | ||
2017/06/26 01:55:47 csd.CreateVolume | ||
2017/06/26 01:55:47 CreateVolume.CapacityRange=<nil> | ||
2017/06/26 01:55:47 CreateVolume.Name=My New Volume | ||
2017/06/26 01:55:47 CreateVolume.Parameters=map[] | ||
2017/06/26 01:55:47 CreateVolume.VolumeCapabilities=[] | ||
2017/06/26 01:55:47 ...Volume.ID=4 | ||
2017/06/26 01:56:04 csd.ListVolumes | ||
2017/06/26 01:56:04 ...Volume.ID=1 | ||
2017/06/26 01:56:04 ...Volume.ID=2 | ||
2017/06/26 01:56:04 ...Volume.ID=3 | ||
2017/06/26 01:56:04 ...Volume.ID=4 | ||
received signal: terminated: shutting down | ||
server stopped gracefully | ||
``` |
Oops, something went wrong.