-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from humblec/release-prep-1
import csi-lib-iscsi to this project
- Loading branch information
Showing
21 changed files
with
2,490 additions
and
207 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
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
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 @@ | ||
*.out | ||
_output | ||
example/example |
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,21 @@ | ||
.PHONY: all build clean install test coverage | ||
|
||
all: clean build install | ||
|
||
clean: | ||
go clean -r -x | ||
-rm -rf _output | ||
|
||
build: | ||
go build ./iscsi/ | ||
go build -o _output/example ./example/main.go | ||
|
||
install: | ||
go install ./iscsi/ | ||
|
||
test: | ||
go test ./iscsi/ | ||
|
||
coverage: | ||
go test ./iscsi -coverprofile=coverage.out | ||
go tool cover -html=coverage.out |
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,8 @@ | ||
# See the OWNERS docs: https://git.k8s.io/community/contributors/guide/owners.md | ||
|
||
approvers: | ||
- saad-ali | ||
- j-griffith | ||
reviews: | ||
- saad-ali | ||
- j-griffith |
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,55 @@ | ||
# csi lib-iscsi | ||
|
||
A simple go package intended to assist CSI plugin authors by providing a tool set to manage iscsi connections. | ||
|
||
## Goals | ||
|
||
Provide a basic, lightweight library for CSI Plugin Authors to leverage some of the common tasks like connecting | ||
and disconnecting iscsi devices to a node. This library includes a high level abstraction for iscsi that exposes | ||
simple Connect and Disconnect functions. These are built on top of exported iscsiadm calls, so if you need more | ||
control you can access the iscsiadm calls directly. | ||
|
||
## Design Philosophy | ||
|
||
The idea is to keep this as lightweight and generic as possible. We intentionally avoid the use of any third party | ||
libraries or packages in this project. We don't have a vendor directory, because we attempt to rely only on the std | ||
golang libs. This may prove to not be ideal, and may be changed over time, but initially it's a worthwhile goal. | ||
|
||
## Logging and Debug | ||
|
||
By default the library does not provide any logging, but provides an error message that includes any messages from | ||
iscsiadm as well as exit-codes. In the event that you need to debug the library, we provide a function: | ||
|
||
``` | ||
func EnableDebugLogging(writer io.Writer) | ||
``` | ||
|
||
This will turn on verbose logging directed to the provided io.Writer and include the response of every iscsiadm command | ||
issued. | ||
|
||
## Intended Usage | ||
|
||
Currently, the intended usage of this library is simply to provide a golang | ||
package to standardize how plugins are implementing | ||
iscsi connect and disconnect. It's not intended to be a "service", | ||
although that's a possible next step. It's currently been | ||
used for plugins where iscsid is installed in containers only, as well as designs where it uses the nodes iscsid. Each of these | ||
approaches has their own pros and cons. Currently, it's up to the plugin author to determine which model suits them best | ||
and to deploy their node plugin appropriately. | ||
|
||
## 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/) | ||
* sig-storage | ||
- [Mailing List](https://groups.google.com/forum/#!forum/kubernetes-dev) | ||
|
||
### Code of conduct | ||
|
||
Participation in the Kubernetes community is governed by the [Kubernetes Code of Conduct](code-of-conduct.md). | ||
|
||
[owners]: https://git.k8s.io/community/contributors/guide/owners.md | ||
[Creative Commons 4.0]: https://git.k8s.io/website/LICENSE |
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,9 @@ | ||
# Release Process | ||
|
||
The Kubernetes Template Project is released on an as-needed basis. The process is as follows: | ||
|
||
1. An issue is proposing a new release with a changelog since the last release | ||
1. All [OWNERS](OWNERS) must LGTM this release | ||
1. An OWNER runs `git tag -s $VERSION` and inserts the changelog and pushes the tag with `git push $VERSION` | ||
1. The release issue is closed | ||
1. An announcement email is sent to `[email protected]` with the subject `[ANNOUNCE] kubernetes-template-project $VERSION is released` |
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,14 @@ | ||
# Defined below are the security contacts for this repo. | ||
# | ||
# They are the contact point for the Product Security Team to reach out | ||
# to for triaging and handling of incoming issues. | ||
# | ||
# The below names 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. | ||
# | ||
# DO NOT REPORT SECURITY VULNERABILITIES DIRECTLY TO THESE NAMES, FOLLOW THE | ||
# INSTRUCTIONS AT https://kubernetes.io/security/ | ||
|
||
childsb | ||
saad-ali |
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 @@ | ||
# Kubernetes Community Code of Conduct | ||
|
||
Please refer to our [Kubernetes Community Code of Conduct](https://git.k8s.io/community/code-of-conduct.md) |
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,71 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"log" | ||
"os" | ||
"strings" | ||
"time" | ||
|
||
"github.com/kubernetes-csi/csi-lib-iscsi/iscsi" | ||
) | ||
|
||
var ( | ||
portals = flag.String("portals", "192.168.1.112:3260", "Comma delimited. Eg: 1.1.1.1,2.2.2.2") | ||
iqn = flag.String("iqn", "iqn.2010-10.org.openstack:volume-95739000-1557-44f8-9f40-e9d29fe6ec47", "") | ||
username = flag.String("username", "3aX7EEf3CEgvESQG75qh", "") | ||
password = flag.String("password", "eJBDC7Bt7WE3XFDq", "") | ||
lun = flag.Int("lun", 1, "") | ||
debug = flag.Bool("debug", false, "enable logging") | ||
) | ||
|
||
func main() { | ||
flag.Parse() | ||
tgtps := strings.Split(*portals, ",") | ||
if *debug { | ||
iscsi.EnableDebugLogging(os.Stdout) | ||
} | ||
|
||
// You can utilize the iscsiadm calls directly if you wish, but by creating a Connector | ||
// you can simplify interactions to simple calls like "Connect" and "Disconnect" | ||
c := &iscsi.Connector{ | ||
// Our example uses chap | ||
AuthType: "chap", | ||
// List of targets must be >= 1 (>1 signals multipath/mpio) | ||
TargetIqn: *iqn, | ||
TargetPortals: tgtps, | ||
// CHAP can be setup up for discovery as well as sessions, our example | ||
// device only uses CHAP security for sessions, for those that use Discovery | ||
// as well, we'd add a DiscoverySecrets entry the same way | ||
SessionSecrets: iscsi.Secrets{ | ||
UserName: *username, | ||
Password: *password, | ||
SecretsType: "chap"}, | ||
// Lun is the lun number the devices uses for exports | ||
Lun: int32(*lun), | ||
// Number of times we check for device path, waiting for CheckInterval seconds in between each check (defaults to 10 if omitted) | ||
RetryCount: 11, | ||
// CheckInterval is the time in seconds to wait in between device path checks when logging in to a target | ||
CheckInterval: 1, | ||
} | ||
|
||
// Now we can just issue a connection request using our Connector | ||
// A successful connection will include the device path to access our iscsi volume | ||
path, err := c.Connect() | ||
if err != nil { | ||
log.Printf("Error returned from c.Connect: %s", err.Error()) | ||
os.Exit(1) | ||
} | ||
|
||
log.Printf("Connected device at path: %s\n", path) | ||
time.Sleep(3 * time.Second) | ||
|
||
// This will disconnect the volume | ||
if err := c.DisconnectVolume(); err != nil { | ||
log.Printf("Error returned from c.DisconnectVolume: %s", err.Error()) | ||
os.Exit(1) | ||
} | ||
|
||
// This will disconnect the session as well as clear out the iscsi DB entries associated with it | ||
c.Disconnect() | ||
} |
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,8 @@ | ||
module github.com/kubernetes-csi/csi-lib-iscsi | ||
|
||
go 1.15 | ||
|
||
require ( | ||
github.com/prashantv/gostub v1.0.0 | ||
github.com/stretchr/testify v1.7.0 | ||
) |
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,13 @@ | ||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/prashantv/gostub v1.0.0 h1:wTzvgO04xSS3gHuz6Vhuo0/kvWelyJxwNS0IRBPAwGY= | ||
github.com/prashantv/gostub v1.0.0/go.mod h1:dP1v6T1QzyGJJKFocwAU0lSZKpfjstjH8TlhkEU0on0= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= | ||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
Oops, something went wrong.