Skip to content

Commit 07b10a3

Browse files
committed
cfs csi driver for k8s
1 parent 7d22778 commit 07b10a3

29 files changed

+2475
-2
lines changed

Gopkg.lock

+681
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
2+
# Gopkg.toml example
3+
#
4+
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
5+
# for detailed Gopkg.toml documentation.
6+
#
7+
# required = ["github.com/user/thing/cmd/thing"]
8+
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
9+
#
10+
# [[constraint]]
11+
# name = "github.com/user/project"
12+
# version = "1.0.0"
13+
#
14+
# [[constraint]]
15+
# name = "github.com/user/project2"
16+
# branch = "dev"
17+
# source = "github.com/myfork/project2"
18+
#
19+
# [[override]]
20+
# name = "github.com/x/y"
21+
# version = "2.4.0"
22+
23+
24+
[[constraint]]
25+
name = "github.com/container-storage-interface/spec"
26+
version = "~0.2.0"
27+
28+
[[constraint]]
29+
branch = "master"
30+
name = "github.com/golang/glog"
31+
32+
[[override]]
33+
revision = "5db89f0ca68677abc5eefce8f2a0a772c98ba52d"
34+
name = "github.com/docker/distribution"
35+
36+
[[constraint]]
37+
branch = "master"
38+
name = "github.com/gophercloud/gophercloud"
39+
40+
[[constraint]]
41+
name = "github.com/pborman/uuid"
42+
version = "1.1.0"
43+
44+
[[constraint]]
45+
name = "github.com/spf13/cobra"
46+
version = "0.0.1"
47+
48+
[[constraint]]
49+
name = "github.com/stretchr/testify"
50+
version = "1.2.1"
51+
52+
#[[constraint]]
53+
# branch = "master"
54+
# name = "golang.org/x/net"
55+
56+
#[[constraint]]
57+
# name = "google.golang.org/grpc"
58+
# version = "1.10.0"
59+
60+
[[constraint]]
61+
name = "gopkg.in/gcfg.v1"
62+
version = "1.2.1"
63+
64+
[[constraint]]
65+
version = "kubernetes-1.10.0-beta.1"
66+
name = "k8s.io/apimachinery"
67+
68+
[[constraint]]
69+
name = "k8s.io/kubernetes"
70+
version = "v1.10.0-beta.1"
71+
72+
[[override]]
73+
version = "kubernetes-1.10.0-beta.1"
74+
name = "k8s.io/api"

Makefile

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright 2017 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
.PHONY: cfs
16+
17+
all: cfs
18+
19+
test:
20+
go test github.com/kubernetes-csi/drivers/pkg/... -cover
21+
go vet github.com/kubernetes-csi/drivers/pkg/...
22+
23+
cfs:
24+
go build -a -ldflags '-extldflags "-static"' -o _output/cfsplugin ./app/cfsplugin
25+
clean:
26+
go clean -r -x
27+
-rm -rf _output

README.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
1-
# containerfs-csi-driver
2-
containerfs csi driver for k8s
1+
[![Build Status](https://travis-ci.org/kubernetes-csi/drivers.svg?branch=master)](https://travis-ci.org/kubernetes-csi/drivers)
2+
# CSI Drivers
3+
4+
These drivers are provided purely for illustrative purposes, and should not be used for production workloads.
5+
6+
## Other sample drivers
7+
Please read [Drivers](https://kubernetes-csi.github.io/docs/Drivers.html) for more information
8+
9+
## Adding new sample drivers
10+
Please, DO NOT submit PRs to add new drivers here unless they are just examples. Real CSI drivers are to be housed on their own repo separate from this one. You are then welcomed to send a PR to https://github.com/kubernetes-csi/docs to add the [Driver](https://github.com/kubernetes-csi/docs/wiki/Drivers) page.

app/cfsplugin/main.go

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
Copyright 2017 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package main
18+
19+
import (
20+
"flag"
21+
"fmt"
22+
"os"
23+
24+
"github.com/kubernetes-csi/drivers/pkg/cfs"
25+
"github.com/spf13/cobra"
26+
)
27+
28+
var (
29+
endpoint string
30+
nodeID string
31+
)
32+
33+
func init() {
34+
flag.Set("logtostderr", "true")
35+
}
36+
37+
func main() {
38+
39+
flag.CommandLine.Parse([]string{})
40+
41+
cmd := &cobra.Command{
42+
Use: "CFS",
43+
Short: "CSI based CFS driver",
44+
Run: func(cmd *cobra.Command, args []string) {
45+
handle()
46+
},
47+
}
48+
49+
cmd.Flags().AddGoFlagSet(flag.CommandLine)
50+
51+
cmd.PersistentFlags().StringVar(&nodeID, "nodeid", "", "node id")
52+
cmd.MarkPersistentFlagRequired("nodeid")
53+
54+
cmd.PersistentFlags().StringVar(&endpoint, "endpoint", "", "CSI endpoint")
55+
cmd.MarkPersistentFlagRequired("endpoint")
56+
57+
if err := cmd.Execute(); err != nil {
58+
fmt.Fprintf(os.Stderr, "%s", err.Error())
59+
os.Exit(1)
60+
}
61+
62+
os.Exit(0)
63+
}
64+
65+
func handle() {
66+
d := cfs.NewDriver(nodeID, endpoint)
67+
d.Run()
68+
}

code-of-conduct.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Kubernetes Community Code of Conduct
2+
3+
Please refer to our [Kubernetes Community Code of Conduct](https://git.k8s.io/community/code-of-conduct.md)

hack/e2e-hostpath.sh

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
3+
## This file is for app/hostpathplugin
4+
## It could be used for other apps in this repo, but
5+
## those applications may or may not take the same
6+
## arguments
7+
8+
## Must be run from the root of the repo
9+
10+
UDS="/tmp/e2e-csi-sanity.sock"
11+
CSI_ENDPOINT="unix://${UDS}"
12+
CSI_MOUNTPOINT="/mnt"
13+
APP=hostpathplugin
14+
15+
SKIP="WithCapacity"
16+
if [ x${TRAVIS} = x"true" ] ; then
17+
SKIP="WithCapacity|NodeUnpublishVolume|NodePublishVolume"
18+
fi
19+
20+
# Get csi-sanity
21+
if [ ! -x $GOPATH/bin/csi-sanity ] ; then
22+
go get -u github.com/kubernetes-csi/csi-test
23+
pushd $GOPATH/src/github.com/kubernetes-csi/csi-test/cmd/csi-sanity
24+
make all
25+
make install
26+
popd
27+
#./hack/get-sanity.sh
28+
fi
29+
30+
# Build
31+
make hostpath
32+
33+
# Cleanup
34+
rm -f $UDS
35+
36+
# Start the application in the background
37+
sudo _output/$APP --endpoint=$CSI_ENDPOINT --nodeid=1 &
38+
pid=$!
39+
40+
# Need to skip Capacity testing since hostpath does not support it
41+
sudo $GOPATH/bin/csi-sanity $@ \
42+
--ginkgo.skip=${SKIP} \
43+
--csi.mountdir=$CSI_MOUNTPOINT \
44+
--csi.endpoint=$CSI_ENDPOINT ; ret=$?
45+
sudo kill -9 $pid
46+
sudo rm -f $UDS
47+
48+
if [ $ret -ne 0 ] ; then
49+
exit $ret
50+
fi
51+
52+
exit 0

hack/get-sanity.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
3+
VERSION="v0.1.0-2"
4+
SANITYTGZ="csi-sanity-${VERSION}.linux.amd64.tar.gz"
5+
6+
if [ ! -x $GOPATH/bin/csi-sanity ] ; then
7+
curl -s -L \
8+
https://github.com/kubernetes-csi/csi-test/releases/download/${VERSION}/${SANITYTGZ} \
9+
-o ${SANITYTGZ} && \
10+
tar xzvf ${SANITYTGZ} -C /tmp && \
11+
rm -f ${SANITYTGZ} && \
12+
cp /tmp/csi-sanity/csi-sanity $GOPATH/bin/csi-sanity && \
13+
rm -rf /tmp/csi-sanity
14+
fi
15+

pkg/cfs/README.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# CSI CFS Driver for K8S
2+
3+
## Kubernetes
4+
### Requirements
5+
6+
The folllowing feature gates and runtime config have to be enabled to deploy the driver
7+
8+
```
9+
FEATURE_GATES=CSIPersistentVolume=true,MountPropagation=true
10+
RUNTIME_CONFIG="storage.k8s.io/v1alpha1=true"
11+
```
12+
13+
Mountprogpation requries support for privileged containers. So, make sure privileged containers are enabled in the cluster.
14+
15+
### Get csi sidecar images
16+
17+
```docker pull quay.io/k8scsi/csi-attacher:v0.2.0```
18+
```docker pull quay.io/k8scsi/driver-registrar:v0.2.0```
19+
```docker pull quay.io/k8scsi/csi-provisioner:v0.2.0```
20+
21+
### Build cfscsi driver image
22+
23+
```docker build -t cfscsi:v1 deploy/.```
24+
25+
### Create configmap for csi driver
26+
27+
```kubectl create configmap kubecfg --from-file=deploy/kubernetes/kubecfg```
28+
29+
### Deploy cfs csi driver
30+
31+
```kubectl create -f deploy/kubernetes/cfs.yaml```
32+
33+
### Pre Volume: you must know volumeName first, example Nginx application
34+
35+
Please update the cfs Master Hosts & volumeName information in nginx-pre.yaml file.
36+
37+
```docker pull nginx```
38+
```kubectl create -f deploy/examples/nginx-pre.yaml```
39+
40+
### Dynamic volume: Example Nginx application
41+
42+
```docker pull nginx```
43+
```kubectl create -f deploy/examples/cfs-pvc.yaml```
44+
```kubectl create -f deploy/examples/cfs-pv.yaml```
45+
```kubectl create -f deploy/examples/nginx-dynamic.yaml```

0 commit comments

Comments
 (0)