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 --drivername option for alternative driver deployments #260

Merged
merged 1 commit into from
May 11, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified charts/latest/csi-driver-smb-v0.7.0.tgz
Binary file not shown.
2 changes: 1 addition & 1 deletion charts/latest/csi-driver-smb/templates/csi-smb-driver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: storage.k8s.io/v1beta1
kind: CSIDriver
metadata:
name: smb.csi.k8s.io
name: {{ .Values.driver.name }}
spec:
attachRequired: false
podInfoOnMount: true
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ spec:
args:
- --v=2
- --csi-address=$(CSI_ENDPOINT)
- --kubelet-registration-path={{ .Values.kubelet.windowsPath }}\\plugins\\smb.csi.k8s.io\\csi.sock
- --kubelet-registration-path={{ .Values.kubelet.windowsPath }}\\plugins\\{{ .Values.driver.name }}\\csi.sock
env:
- name: CSI_ENDPOINT
value: unix://C:\\csi\\csi.sock
Expand All @@ -75,6 +75,7 @@ spec:
imagePullPolicy: {{ .Values.image.smb.pullPolicy }}
args:
- "--v={{ .Values.node.logLevel }}"
- "--drivername={{ .Values.driver.name }}"
- --endpoint=$(CSI_ENDPOINT)
- --nodeid=$(KUBE_NODE_NAME)
- "--metrics-address=0.0.0.0:{{ .Values.node.metricsPort }}"
Expand Down Expand Up @@ -136,6 +137,6 @@ spec:
type: Directory
- name: plugin-dir
hostPath:
path: {{ .Values.kubelet.windowsPath }}\plugins\smb.csi.k8s.io\
path: {{ .Values.kubelet.windowsPath }}\plugins\{{ .Values.driver.name }}\
type: DirectoryOrCreate
{{- end -}}
7 changes: 4 additions & 3 deletions charts/latest/csi-driver-smb/templates/csi-smb-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ spec:
lifecycle:
preStop:
exec:
command: ["/bin/sh", "-c", "rm -rf /registration/smb.csi.k8s.io-reg.sock /csi/csi.sock"]
command: ["/bin/sh", "-c", "rm -rf /registration/{{ .Values.driver.name }}-reg.sock /csi/csi.sock"]
env:
- name: ADDRESS
value: /csi/csi.sock
- name: DRIVER_REG_SOCK_PATH
value: {{ .Values.kubelet.linuxPath }}/plugins/smb.csi.k8s.io/csi.sock
value: {{ .Values.kubelet.linuxPath }}/plugins/{{ .Values.driver.name }}/csi.sock
imagePullPolicy: {{ .Values.image.nodeDriverRegistrar.pullPolicy }}
volumeMounts:
- name: socket-dir
Expand All @@ -74,6 +74,7 @@ spec:
imagePullPolicy: {{ .Values.image.smb.pullPolicy }}
args:
- "--v={{ .Values.node.logLevel }}"
- "--drivername={{ .Values.driver.name }}"
- "--endpoint=$(CSI_ENDPOINT)"
- "--nodeid=$(KUBE_NODE_NAME)"
- "--metrics-address=0.0.0.0:{{ .Values.node.metricsPort }}"
Expand Down Expand Up @@ -117,7 +118,7 @@ spec:
memory: 20Mi
volumes:
- hostPath:
path: {{ .Values.kubelet.linuxPath }}/plugins/smb.csi.k8s.io
path: {{ .Values.kubelet.linuxPath }}/plugins/{{ .Values.driver.name }}
type: DirectoryOrCreate
name: socket-dir
- hostPath:
Expand Down
3 changes: 3 additions & 0 deletions charts/latest/csi-driver-smb/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ serviceAccount:
rbac:
create: true

driver:
name: smb.csi.k8s.io

controller:
replicas: 2
metricsPort: 29644
Expand Down
6 changes: 3 additions & 3 deletions pkg/smb/smb.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
)

const (
DriverName = "smb.csi.k8s.io"
DefaultDriverName = "smb.csi.k8s.io"
createSubDirField = "createsubdir"
)

Expand All @@ -44,9 +44,9 @@ type Driver struct {

// NewDriver Creates a NewCSIDriver object. Assumes vendor version is equal to driver version &
// does not support optional driver plugin info manifest field. Refer to CSI spec for more details.
func NewDriver(nodeID string) *Driver {
func NewDriver(nodeID, driverName string) *Driver {
driver := Driver{}
driver.Name = DriverName
driver.Name = driverName
driver.Version = driverVersion
driver.NodeID = nodeID
driver.volumeLocks = newVolumeLocks()
Expand Down
4 changes: 2 additions & 2 deletions pkg/smb/smb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ const (
)

func NewFakeDriver() *Driver {
return NewDriver(fakeNodeID)
return NewDriver(fakeNodeID, DefaultDriverName)
}

func TestNewFakeDriver(t *testing.T) {
// Test New fake driver.
d := NewDriver(fakeNodeID)
d := NewDriver(fakeNodeID, DefaultDriverName)
assert.NotNil(t, d)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/smb/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type VersionInfo struct {
// GetVersion returns the version information of the driver
func GetVersion() VersionInfo {
return VersionInfo{
DriverName: DriverName,
DriverName: DefaultDriverName,
DriverVersion: driverVersion,
GitCommit: gitCommit,
BuildDate: buildDate,
Expand Down
2 changes: 1 addition & 1 deletion pkg/smb/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestGetVersion(t *testing.T) {
version := GetVersion()

expected := VersionInfo{
DriverName: DriverName,
DriverName: DefaultDriverName,
DriverVersion: "N/A",
GitCommit: "N/A",
BuildDate: "N/A",
Expand Down
3 changes: 2 additions & 1 deletion pkg/smbplugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func init() {
var (
endpoint = flag.String("endpoint", "unix://tmp/csi.sock", "CSI endpoint")
nodeID = flag.String("nodeid", "", "node id")
driverName = flag.String("drivername", smb.DefaultDriverName, "name of the driver")
version = flag.Bool("version", false, "Print the version and exit.")
metricsAddress = flag.String("metrics-address", "0.0.0.0:29644", "export the metrics")
kubeconfig = flag.String("kubeconfig", "", "Absolute path to the kubeconfig file. Required only when running out of cluster.")
Expand All @@ -63,7 +64,7 @@ func main() {
}

func handle() {
driver := smb.NewDriver(*nodeID)
driver := smb.NewDriver(*nodeID, *driverName)
if driver == nil {
klog.Fatalln("Failed to initialize smb CSI Driver")
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/driver/smb_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type SMBDriver struct {
func InitSMBDriver() PVTestDriver {
driverName := os.Getenv(SMBDriverNameVar)
if driverName == "" {
driverName = smb.DriverName
driverName = smb.DefaultDriverName
}

klog.Infof("Using smb driver: %s", driverName)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ var _ = ginkgo.BeforeSuite(func() {

nodeid := os.Getenv("nodeid")
kubeconfig := os.Getenv(kubeconfigEnvVar)
smbDriver = smb.NewDriver(nodeid)
smbDriver = smb.NewDriver(nodeid, smb.DefaultDriverName)
go func() {
smbDriver.Run(fmt.Sprintf("unix:///tmp/csi-%s.sock", uuid.NewUUID().String()), kubeconfig, false)
}()
Expand Down