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

CNS CSI Driver #52

Merged
merged 1 commit into from
Sep 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 40 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,52 @@ endif # ifndef X_BUILD_DISABLED
## TESTING ##
################################################################################
ifndef PKGS_WITH_TESTS
export PKGS_WITH_TESTS := $(sort $(shell find . -name "*_test.go" -type f -exec dirname \{\} \;))
export PKGS_WITH_TESTS := $(sort $(shell find . -path ./tests -prune -o -name "*_test.go" -type f -exec dirname \{\} \;))
endif
TEST_FLAGS ?= -v
TEST_FLAGS ?= -v -count=1
.PHONY: unit build-unit-tests
unit unit-test:
go test $(TEST_FLAGS) $(PKGS_WITH_TESTS)
env -u VSPHERE_VCENTER -u VSPHERE_DATACENTER -u VSPHERE_PASSWORD -u VSPHERE_USER -u VSPHERE_DATASTORE_URL -u VSPHERE_STORAGE_POLICY_NAME -u VSPHERE_K8S_NODE -u VSPHERE_INSECURE -u KUBECONFIG go test $(TEST_FLAGS) $(PKGS_WITH_TESTS)
build-unit-tests:
$(foreach pkg,$(PKGS_WITH_TESTS),go test $(TEST_FLAGS) -c $(pkg); )

.PHONY: integration-unit-test
integration-unit-test:
ifndef VSPHERE_VCENTER
$(error Requires VSPHERE_VCENTER from a deployed testbed to run integration-unit-test)
endif
ifndef VSPHERE_USER
$(error Requires VSPHERE_USER from a deployed testbed to run integration-unit-test)
endif
ifndef VSPHERE_PASSWORD
$(error Requires VSPHERE_PASSWORD from a deployed testbed to run integration-unit-test)
endif
ifndef VSPHERE_DATACENTER
$(error Requires VSPHERE_DATACENTER from a deployed testbed to run integration-unit-test)
endif
ifndef VSPHERE_DATASTORE_URL
$(error Requires VSPHERE_DATASTORE_URL from a deployed testbed to run integration-unit-test)
endif
ifndef VSPHERE_K8S_NODE
$(error Requires VSPHERE_K8S_NODE from a deployed testbed to run integration-unit-test)
endif
ifndef KUBECONFIG
$(error Requires KUBECONFIG from a deployed testbed to run integration-unit-test)
endif
ifndef VSPHERE_INSECURE
$(error Requires VSPHERE_INSECURE from a deployed testbed to run integration-unit-test)
endif
go test $(TEST_FLAGS) -tags=integration-unit ./pkg/csi/service/cns

# The default test target.
.PHONY: test build-tests
test: unit
build-tests: build-unit-tests

.PHONY: cover
cover: TEST_FLAGS += -cover
cover: test

# The default test target.
.PHONY: test build-tests
test: unit
Expand Down
21 changes: 7 additions & 14 deletions cmd/vsphere-csi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@ package main

import (
"context"
"flag"

"github.com/rexray/gocsi"
"k8s.io/klog"

"sigs.k8s.io/vsphere-csi-driver/pkg/csi/provider"
"sigs.k8s.io/vsphere-csi-driver/pkg/csi/service"
)

// main is ignored when this package is built as a go plug-in.
func main() {
klog.InitFlags(nil)
flag.Parse()
gocsi.Run(
context.Background(),
service.Name,
Expand All @@ -35,19 +39,8 @@ func main() {
provider.New())
}

const usage = ` X_CSI_VSPHERE_APINAME
Specifies the name of the API to use when talking to vCenter
const usage = ` VSPHERE_CSI_CONFIG
Specifies the path to the csi-vsphere.conf file

The default value is "FCD" (First Class Disk)

X_CSI_VSPHERE_CLOUD_CONFIG
Specifies the path to the vsphere.conf file

The default falue is "/etc/cloud/vsphere.conf"

X_CSI_DISABLE_K8S_CLIENT
Boolean flag that disables the Kubernetes API client to retrieve
secrets.

The default value is "false"
The default value is "/etc/cloud/csi-vsphere.conf"
`
17 changes: 17 additions & 0 deletions example/example-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Pod
metadata:
name: example-vanilla-block-pod
spec:
containers:
- name: test-container
image: gcr.io/google_containers/busybox:1.24
command: ["/bin/sh", "-c", "echo 'hello' > /mnt/volume1/index.html && chmod o+rX /mnt /mnt/volume1/index.html && while true ; do sleep 2 ; done"]
volumeMounts:
- name: test-volume
mountPath: /mnt/volume1
restartPolicy: Never
volumes:
- name: test-volume
persistentVolumeClaim:
claimName: example-vanilla-block-pvc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: vsphere-csi-pvc
name: example-vanilla-block-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
storageClassName: vsphere-fcd
storageClassName: example-vanilla-block-sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: example-vanilla-block-sc
provisioner: csi.vsphere.vmware.com
volumeBindingMode: WaitForFirstConsumer
allowedTopologies:
- matchLabelExpressions:
- key: failure-domain.beta.kubernetes.io/zone
values:
- k8s-region-eu-all
- k8s-zone-us-west
- key: failure-domain.beta.kubernetes.io/region
values:
- k8s-region-eu
- k8s-region-us
14 changes: 14 additions & 0 deletions example/example-sc-WaitForFirstConsumer-with-topology.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: example-vanilla-block-sc
provisioner: csi.vsphere.vmware.com
volumeBindingMode: WaitForFirstConsumer
allowedTopologies:
- matchLabelExpressions:
- key: failure-domain.beta.kubernetes.io/zone
values:
- k8s-region-eu-all
- key: failure-domain.beta.kubernetes.io/region
values:
- k8s-region-eu
6 changes: 6 additions & 0 deletions example/example-sc-WaitForFirstConsumer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: example-vanilla-block-sc
provisioner: csi.vsphere.vmware.com
volumeBindingMode: WaitForFirstConsumer
15 changes: 15 additions & 0 deletions example/example-sc-multiple-zones-regions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: example-vanilla-block-sc
provisioner: csi.vsphere.vmware.com
allowedTopologies:
- matchLabelExpressions:
- key: failure-domain.beta.kubernetes.io/zone
values:
- k8s-zone-us-west
- k8s-region-eu-all
- key: failure-domain.beta.kubernetes.io/region
values:
- k8s-region-us
- k8s-region-eu
14 changes: 14 additions & 0 deletions example/example-sc-multiple-zones.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: example-vanilla-block-sc
provisioner: csi.vsphere.vmware.com
allowedTopologies:
- matchLabelExpressions:
- key: failure-domain.beta.kubernetes.io/zone
values:
- k8s-zone-us-east
- k8s-zone-us-west
- key: failure-domain.beta.kubernetes.io/region
values:
- k8s-region-us
15 changes: 15 additions & 0 deletions example/example-sc-zone.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: example-vanilla-block-sc
annotations:
storageclass.kubernetes.io/is-default-class: "true"
provisioner: csi.vsphere.vmware.com
allowedTopologies:
- matchLabelExpressions:
- key: failure-domain.beta.kubernetes.io/zone
values:
- k8s-zone-us-west
- key: failure-domain.beta.kubernetes.io/region
values:
- k8s-region-us
11 changes: 11 additions & 0 deletions example/example-sc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: example-vanilla-block-sc
annotations:
storageclass.kubernetes.io/is-default-class: "true"
provisioner: csi.vsphere.vmware.com
parameters:
datastoreurl: "ds:///vmfs/volumes/vsan:52cdfa80721ff516-ea1e993113acfc77/" #Optional Parameter
storagepolicyname: "vSAN Default Storage Policy" #Optional Parameter
fstype: "ext4" #Optional Parameter
68 changes: 49 additions & 19 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,63 @@ require (
github.com/akutz/gosync v0.1.0 // indirect
github.com/akutz/memconn v0.1.0
github.com/container-storage-interface/spec v1.0.0
github.com/coreos/bbolt v1.3.3 // indirect
github.com/coreos/etcd v3.3.15+incompatible // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f // indirect
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/davecgh/go-spew v1.1.1
github.com/evanphx/json-patch v4.5.0+incompatible // indirect
github.com/gogo/protobuf v1.3.0 // indirect
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 // indirect
github.com/google/btree v1.0.0 // indirect
github.com/google/uuid v1.1.1 // indirect
github.com/gregjones/httpcache v0.0.0-20190212212710-3befbb6ad0cc // indirect
github.com/google/go-cmp v0.3.1 // indirect
github.com/googleapis/gnostic v0.3.1 // indirect
github.com/gorilla/websocket v1.4.1 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.11.1 // indirect
github.com/hashicorp/golang-lru v0.5.3 // indirect
github.com/imdario/mergo v0.3.7 // indirect
github.com/onsi/ginkgo v1.8.0
github.com/onsi/gomega v1.4.3
github.com/rexray/gocsi v0.4.1-0.20181205192803-207653674028
github.com/sirupsen/logrus v1.4.1
github.com/jonboulle/clockwork v0.1.0 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/onsi/ginkgo v1.10.1
github.com/onsi/gomega v1.7.0
github.com/pkg/errors v0.8.1 // indirect
github.com/prometheus/client_golang v1.1.0 // indirect
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 // indirect
github.com/prometheus/procfs v0.0.4 // indirect
github.com/rexray/gocsi v1.0.0
github.com/sirupsen/logrus v1.4.2 // indirect
github.com/soheilhy/cmux v0.1.4 // indirect
github.com/stretchr/testify v1.4.0 // indirect
github.com/thecodeteam/gofsutil v0.1.2 // indirect
github.com/thecodeteam/gosync v0.1.0 // indirect
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
github.com/vmware/govmomi v0.21.1-0.20190821201433-8bdc2d6fc858
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586 // indirect
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
go.etcd.io/bbolt v1.3.3 // indirect
go.uber.org/atomic v1.4.0 // indirect
go.uber.org/multierr v1.1.0 // indirect
go.uber.org/zap v1.10.0 // indirect
golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472 // indirect
golang.org/x/lint v0.0.0-20190409202823-959b441ac422 // indirect
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456 // indirect
golang.org/x/text v0.3.2 // indirect
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 // indirect
golang.org/x/sys v0.0.0-20190904005037-43c01164e931 // indirect
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
golang.org/x/tools v0.0.0-20190827205025-b29f5f60c37a // indirect
google.golang.org/grpc v1.19.0
golang.org/x/tools v0.0.0-20190903163617-be0da057c5e3 // indirect
google.golang.org/appengine v1.6.2 // indirect
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 // indirect
google.golang.org/grpc v1.23.0
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/gcfg.v1 v1.2.3
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
honnef.co/go/tools v0.0.1-2019.2.2 // indirect
k8s.io/apimachinery v0.0.0-20180621070125-103fd098999d
k8s.io/client-go v8.0.0+incompatible
k8s.io/cloud-provider-vsphere v0.2.1
k8s.io/klog v0.2.0
k8s.io/kubernetes v1.11.2
k8s.io/sample-controller v0.0.0-20180822125000-be98dc6210ab
k8s.io/utils v0.0.0-20190308190857-21c4ce38f2a7 // indirect
k8s.io/api v0.0.0-20190831074750-7364b6bdad65
k8s.io/apimachinery v0.0.0-20190831074630-461753078381
k8s.io/client-go v0.0.0-20190831074946-3fe2abece89e
k8s.io/klog v0.4.0
k8s.io/sample-controller v0.0.0-20190831080103-b17b22266fdc
k8s.io/utils v0.0.0-20190829053155-3a4a5477acf8 // indirect
)