Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add iscsi csi driver #1

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
813 changes: 813 additions & 0 deletions Gopkg.lock

Large diffs are not rendered by default.

85 changes: 85 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@

# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"

[prune]
go-tests = true
unused-packages = true

[[constraint]]
name = "github.com/container-storage-interface/spec"
version = "1.0.0"

[[constraint]]
branch = "master"
name = "github.com/golang/glog"

[[override]]
revision = "5db89f0ca68677abc5eefce8f2a0a772c98ba52d"
name = "github.com/docker/distribution"

[[constraint]]
name = "github.com/pborman/uuid"
version = "1.1.0"

[[constraint]]
name = "github.com/spf13/cobra"
version = "0.0.1"

[[constraint]]
name = "github.com/stretchr/testify"
version = "1.2.1"

[[constraint]]
branch = "master"
name = "golang.org/x/net"

[[constraint]]
name = "google.golang.org/grpc"
version = "1.10.0"

[[constraint]]
name = "k8s.io/kubernetes"
version = "v1.12.0"

[[override]]
version = "kubernetes-1.12.0"
name = "k8s.io/api"

[[override]]
version = "kubernetes-1.12.0"
name = "k8s.io/apiserver"

[[override]]
name = "github.com/golang/protobuf"
version = "v1.1.0"

[[override]]
name = "github.com/json-iterator/go"
version = "1.1.4"

[[override]]
name = "gopkg.in/square/go-jose.v2"
version = "2.1.7"

[[constraint]]
name = "github.com/kubernetes-csi/csi-lib-utils"
version = "0.2.0"
41 changes: 41 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2017 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.

REGISTRY_NAME=quay.io/k8scsi
IMAGE_NAME=iscsiplugin
IMAGE_VERSION=canary
IMAGE_TAG=$(REGISTRY_NAME)/$(IMAGE_NAME):$(IMAGE_VERSION)
REV=$(shell git describe --long --tags --dirty)

.PHONY: all iscsi clean iscsi-container

all: iscsi

test:
go test github.com/kubernetes-csi/drivers/pkg/... -cover
go vet github.com/kubernetes-csi/drivers/pkg/...

iscsi:
if [ ! -d ./vendor ]; then dep ensure -vendor-only; fi
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o _output/iscsiplugin ./app/

iscsi-container: iscsi
docker build -t $(IMAGE_TAG) -f ./app/iscsiplugin/Dockerfile .

push: iscsi-container
docker push $(IMAGE_TAG)

clean:
go clean -r -x
-rm -rf _output
54 changes: 39 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,49 @@
# Kubernetes Template Project

The Kubernetes Template Project is a template for starting new projects in the GitHub organizations owned by Kubernetes. All Kubernetes projects, at minimum, must have the following files:

- a `README.md` outlining the project goals, sponsoring sig, and community contact information
- an `OWNERS` with the project leads listed as approvers ([docs on `OWNERS` files][owners])
- a `CONTRIBUTING.md` outlining how to contribute to the project
- an unmodified copy of `code-of-conduct.md` from this repo, which outlines community behavior and the consequences of breaking the code
- a `LICENSE` which must be Apache 2.0 for code projects, or [Creative Commons 4.0] for documentation repositories, without any custom content
- a `SECURITY_CONTACTS` with the contact points for the Product Security Team
to reach out to for triaging and handling of incoming issues. They must agree to abide by the
[Embargo Policy](https://github.com/kubernetes/sig-release/blob/master/security-release-process-documentation/security-release-process.md#embargo-policy)
and will be removed and replaced if they violate that agreement.
# CSI ISCSI driver

## Usage:

### Start ISCSI driver
```
$ sudo ./_output/iscsidriver --endpoint tcp://127.0.0.1:10000 --nodeid CSINode
```

### Test using csc
Get ```csc``` tool from https://github.com/rexray/gocsi/tree/master/csc

#### Get plugin info
```
$ csc identity plugin-info --endpoint tcp://127.0.0.1:10000
"ISCSI" "0.1.0"
```

#### NodePublish a volume
```
$ export ISCSI_TARGET="iSCSI Target Server IP (Ex: 10.10.10.10)"
$ export IQN="Target IQN"
$ csc node publish --endpoint tcp://127.0.0.1:10000 --target-path /mnt/iscsi --attrib targetPortal=$ISCSI_TARGET --attrib iqn=$IQN --attrib lun=<lun-id> iscsitestvol
iscsitestvol
```

#### NodeUnpublish a volume
```
$ csc node unpublish --endpoint tcp://127.0.0.1:10000 --target-path /mnt/iscsi iscsitestvol
iscsitestvol
```

#### Get NodeID
```
$ csc node get-id --endpoint tcp://127.0.0.1:10000
CSINode
```

## Community, discussion, contribution, and support

Learn how to engage with the Kubernetes community on the [community page](http://kubernetes.io/community/).

You can reach the maintainers of this project at:

- [Slack](http://slack.k8s.io/)
- [Mailing List](https://groups.google.com/forum/#!forum/kubernetes-dev)
- [Slack channel](https://kubernetes.slack.com/messages/sig-storage)
- [Mailing list](https://groups.google.com/forum/#!forum/kubernetes-sig-storage)

### Code of conduct

Expand Down
69 changes: 69 additions & 0 deletions app/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
Copyright 2017 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.
*/

package main

import (
"flag"
"fmt"
"os"

"github.com/spf13/cobra"

"github.com/kubernetes-csi/csi-driver-iscsi/pkg/iscsi"
)

var (
endpoint string
nodeID string
)

func init() {
flag.Set("logtostderr", "true")
}

func main() {

flag.CommandLine.Parse([]string{})

cmd := &cobra.Command{
Use: "ISCSI",
Short: "CSI based ISCSI driver",
Run: func(cmd *cobra.Command, args []string) {
handle()
},
}

cmd.Flags().AddGoFlagSet(flag.CommandLine)

cmd.PersistentFlags().StringVar(&nodeID, "nodeid", "", "node id")
cmd.MarkPersistentFlagRequired("nodeid")

cmd.PersistentFlags().StringVar(&endpoint, "endpoint", "", "CSI endpoint")
cmd.MarkPersistentFlagRequired("endpoint")

if err := cmd.Execute(); err != nil {
fmt.Fprintf(os.Stderr, "%s", err.Error())
os.Exit(1)
}

os.Exit(0)
}

func handle() {
d := iscsi.NewDriver(nodeID, endpoint)
d.Run()
}
68 changes: 68 additions & 0 deletions pkg/iscsi/driver.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
Copyright 2017 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.
*/

package iscsi

import (
"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/golang/glog"

csicommon "github.com/kubernetes-csi/drivers/pkg/csi-common"
)

type driver struct {
csiDriver *csicommon.CSIDriver
endpoint string

ids *csicommon.DefaultIdentityServer
ns *nodeServer

cap []*csi.VolumeCapability_AccessMode
cscap []*csi.ControllerServiceCapability
}

const (
driverName = "ISCSI"
)

var (
version = "1.0.0-rc2"
)

func NewDriver(nodeID, endpoint string) *driver {
glog.Infof("Driver: %v version: %v", driverName, version)

d := &driver{}

d.endpoint = endpoint

csiDriver := csicommon.NewCSIDriver(driverName, version, nodeID)
csiDriver.AddVolumeCapabilityAccessModes([]csi.VolumeCapability_AccessMode_Mode{csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER})

d.csiDriver = csiDriver

return d
}

func NewNodeServer(d *driver) *nodeServer {
return &nodeServer{
DefaultNodeServer: csicommon.NewDefaultNodeServer(d.csiDriver),
}
}

func (d *driver) Run() {
csicommon.RunNodePublishServer(d.endpoint, d.csiDriver, NewNodeServer(d))
}
Loading