Skip to content

Commit

Permalink
feat: migrate to csi proxy v2 alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-ding committed Nov 1, 2022
1 parent a524d2c commit e6b3ba1
Show file tree
Hide file tree
Showing 73 changed files with 2,451 additions and 13,398 deletions.
2 changes: 2 additions & 0 deletions Dockerfile.Windows
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ RUN cd /code/ && GOARCH=$(echo $TARGETPLATFORM | cut -f2 -d '/') GCE_PD_CSI_STAG

FROM ${BASE_IMAGE}
LABEL description="PD CSI driver"
ENV PATH="${PATH};c:\\Windows\\System32\\WindowsPowerShell\\v1.0"

COPY --from=builder /code/bin/gce-pd-csi-driver.exe /gce-pd-csi-driver.exe

USER ContainerAdministrator
Expand Down
78 changes: 16 additions & 62 deletions deploy/kubernetes/base/node_windows/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,21 @@ spec:
serviceAccountName: csi-gce-pd-node-sa-win
nodeSelector:
kubernetes.io/os: windows
hostNetwork: true
securityContext:
windowsOptions:
hostProcess: true
runAsUserName: "NT AUTHORITY\\SYSTEM"
containers:
- name: csi-driver-registrar
image: k8s.gcr.io/sig-storage/csi-node-driver-registrar
command:
- csi-node-driver-registrar.exe
args:
- --v=5
- --csi-address=unix://C:\\csi\\csi.sock
- --kubelet-registration-path=C:\\var\\lib\\kubelet\\plugins\\pd.csi.storage.gke.io\\csi.sock
- --csi-address=unix://c:\var\lib\kubelet\plugins\pd.csi.storage.gke.io\csi.sock
- --kubelet-registration-path=/var/lib/kubelet/plugins/pd.csi.storage.gke.io/csi.sock
- --plugin-registration-path=/var/lib/kubelet/plugins_registry
env:
- name: KUBE_NODE_NAME
valueFrom:
Expand All @@ -37,74 +45,20 @@ spec:
volumeMounts:
- name: plugin-dir
mountPath: /csi
- name: registration-dir
mountPath: /registration
- name: gce-pd-driver
# Don't change base image without changing pdImagePlaceholder in
# test/k8s-integration/main.go
image: gke.gcr.io/gcp-compute-persistent-disk-csi-driver
command:
- gce-pd-csi-driver.exe
args:
- "--v=5"
- "--endpoint=unix:/csi/csi.sock"
- "--run-controller-service=false"
volumeMounts:
- name: kubelet-dir
mountPath: C:\var\lib\kubelet
mountPropagation: "None"
- name: plugin-dir
mountPath: C:\csi
- name: csi-proxy-volume-v1
mountPath: \\.\pipe\csi-proxy-volume-v1
- name: csi-proxy-filesystem-v1
mountPath: \\.\pipe\csi-proxy-filesystem-v1
- name: csi-proxy-disk-v1
mountPath: \\.\pipe\csi-proxy-disk-v1
# these paths are still included for compatibility, they're used
# only if the node has still the beta version of the CSI proxy
- name: csi-proxy-volume-v1beta1
mountPath: \\.\pipe\csi-proxy-volume-v1beta1
- name: csi-proxy-filesystem-v1beta1
mountPath: \\.\pipe\csi-proxy-filesystem-v1beta1
- name: csi-proxy-disk-v1beta2
mountPath: \\.\pipe\csi-proxy-disk-v1beta2
- --v=5
- --endpoint=unix:/c:\var\lib\kubelet\plugins\pd.csi.storage.gke.io\csi.sock
- --run-controller-service=false
volumes:
- name: csi-proxy-disk-v1
hostPath:
path: \\.\pipe\csi-proxy-disk-v1
type: ""
- name: csi-proxy-volume-v1
hostPath:
path: \\.\pipe\csi-proxy-volume-v1
type: ""
- name: csi-proxy-filesystem-v1
hostPath:
path: \\.\pipe\csi-proxy-filesystem-v1
type: ""
# these paths are still included for compatibility, they're used
# only if the node has still the beta version of the CSI proxy
- name: csi-proxy-disk-v1beta2
hostPath:
path: \\.\pipe\csi-proxy-disk-v1beta2
type: ""
- name: csi-proxy-volume-v1beta1
hostPath:
path: \\.\pipe\csi-proxy-volume-v1beta1
type: ""
- name: csi-proxy-filesystem-v1beta1
hostPath:
path: \\.\pipe\csi-proxy-filesystem-v1beta1
type: ""
- name: registration-dir
hostPath:
path: \var\lib\kubelet\plugins_registry
type: Directory
- name: kubelet-dir
hostPath:
path: \var\lib\kubelet
type: Directory
- name: plugin-dir
hostPath:
path: \var\lib\kubelet\plugins\pd.csi.storage.gke.io
path: /var/lib/kubelet/plugins/pd.csi.storage.gke.io
type: DirectoryOrCreate
tolerations:
- operator: Exists
9 changes: 0 additions & 9 deletions docs/local-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,3 @@ Running Unit Tests:
```
$ ./test/run-unit.sh
```

## Dependency Management

Use [dep](https://github.com/golang/dep)
```
$ dep ensure
```

To modify dependencies or versions change `./Gopkg.toml`
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/GoogleCloudPlatform/k8s-cloud-provider v1.18.0
github.com/container-storage-interface/spec v1.6.0
github.com/google/uuid v1.3.0
github.com/kubernetes-csi/csi-proxy/client v1.1.1
github.com/kubernetes-csi/csi-proxy/v2 v2.0.0-alpha.0
github.com/kubernetes-csi/csi-test/v4 v4.4.0
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.20.0
Expand All @@ -32,7 +32,6 @@ require (
require (
cloud.google.com/go v0.103.0 // indirect
cloud.google.com/go/iam v0.3.0 // indirect
github.com/Microsoft/go-winio v0.4.17 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand Down Expand Up @@ -64,7 +63,6 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.12.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
Expand Down
8 changes: 3 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@ github.com/Masterminds/vcs v1.13.1/go.mod h1:N09YCmOQr6RLxC6UNHzuVwAdodYbbnycGHS
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw=
github.com/Microsoft/go-winio v0.4.15/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw=
github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0=
github.com/Microsoft/go-winio v0.4.17 h1:iT12IBVClFevaf8PuVyi3UmZOVh4OqnaLxDTW2O6j3w=
github.com/Microsoft/go-winio v0.4.17/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
github.com/Microsoft/hcsshim v0.8.7/go.mod h1:OHd7sQqRFrYd3RmSgbgji+ctCwkbq2wbEYNSzOYtcBQ=
github.com/Microsoft/hcsshim v0.8.22/go.mod h1:91uVCVzvX2QD16sMCenoxxXo6L1wJnLMX2PSufFMtF0=
Expand Down Expand Up @@ -1048,8 +1046,8 @@ github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kubernetes-csi/csi-proxy/client v1.1.1 h1:GagYqArF85E/pQuzldTEQ3WmrcNVU/bYPNG+Ha8tTC4=
github.com/kubernetes-csi/csi-proxy/client v1.1.1/go.mod h1:SfK4HVKQdMH5KrffivddAWgX5hl3P5KmnuOTBbDNboU=
github.com/kubernetes-csi/csi-proxy/v2 v2.0.0-alpha.0 h1:9uY7OxvgKhDqqEuSCDW++cZcYlHFVTwhbEdZa5XqJCQ=
github.com/kubernetes-csi/csi-proxy/v2 v2.0.0-alpha.0/go.mod h1:pacx+PW7lLlu6kAvpr8Lgq/5fdiAsKxOtXXFHMaLMb8=
github.com/kubernetes-csi/csi-test/v4 v4.4.0 h1:r0mnAwDURI24Vw3a/LyA/ga11yD5ZGuU7+REO35Na9s=
github.com/kubernetes-csi/csi-test/v4 v4.4.0/go.mod h1:t1RzseMZJKy313nezI/d7TolbbiKpUZM3SXQvXxOX0w=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
Expand Down Expand Up @@ -1273,7 +1271,6 @@ github.com/pierrec/lz4 v2.2.6+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1-0.20171018195549-f15c970de5b7/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
Expand Down Expand Up @@ -2457,6 +2454,7 @@ k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
k8s.io/klog/v2 v2.4.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
k8s.io/klog/v2 v2.8.0/go.mod h1:hy9LJ/NvuK+iVyP4Ehqva4HxZG/oXyIS3n3Jmire4Ec=
k8s.io/klog/v2 v2.9.0/go.mod h1:hy9LJ/NvuK+iVyP4Ehqva4HxZG/oXyIS3n3Jmire4Ec=
k8s.io/klog/v2 v2.60.1 h1:VW25q3bZx9uE3vvdL6M8ezOX79vA2Aq1nEWLqNQclHc=
k8s.io/klog/v2 v2.60.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
k8s.io/kube-aggregator v0.24.1/go.mod h1:vZvRALCO32hrIuREhkYwLq5Crc0zh6SxzJDAKrQM1+k=
Expand Down
3 changes: 1 addition & 2 deletions pkg/gce-pd-csi-driver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package gceGCEDriver

import (
"net"
"net/url"
"os"
"path/filepath"
"sync"
Expand Down Expand Up @@ -75,7 +74,7 @@ func (s *nonBlockingGRPCServer) serve(endpoint string, ids csi.IdentityServer, c
grpc.UnaryInterceptor(logGRPC),
}

u, err := url.Parse(endpoint)
u, err := parseEndpoint(endpoint)

if err != nil {
klog.Fatal(err.Error())
Expand Down
5 changes: 5 additions & 0 deletions pkg/gce-pd-csi-driver/utils_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package gceGCEDriver

import (
"fmt"
"net/url"
"os"
"strconv"
"strings"
Expand Down Expand Up @@ -79,3 +80,7 @@ func getBlockSizeBytes(devicePath string, m *mount.SafeFormatAndMount) (int64, e
}
return gotSizeBytes, nil
}

func parseEndpoint(endpoint string) (*url.URL, error) {
return url.Parse(endpoint)
}
15 changes: 15 additions & 0 deletions pkg/gce-pd-csi-driver/utils_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package gceGCEDriver

import (
"fmt"
"net/url"
"strings"

"k8s.io/mount-utils"
Expand Down Expand Up @@ -100,3 +101,17 @@ func getBlockSizeBytes(devicePath string, m *mount.SafeFormatAndMount) (int64, e
}
return proxy.GetDiskTotalBytes(devicePath)
}

func parseEndpoint(endpoint string) (*url.URL, error) {
u, err := url.Parse(endpoint)
if err != nil {
return nil, err
}
if u.Scheme == "unix" {
// remove leading slashes
if len(u.Path) > 0 && string(u.Path[0]) == "/" {
u.Path = u.Path[1:]
}
}
return u, err
}
Loading

0 comments on commit e6b3ba1

Please sign in to comment.