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

Migrate to csi proxy v2 alpha #1071

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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile.Windows
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

ARG BASE_IMAGE
FROM --platform=$BUILDPLATFORM golang:1.17.8 AS builder

ARG TARGETPLATFORM
Expand All @@ -22,8 +21,9 @@ WORKDIR /code
ADD . /code/
RUN cd /code/ && GOARCH=$(echo $TARGETPLATFORM | cut -f2 -d '/') GCE_PD_CSI_STAGING_VERSION=${STAGINGVERSION} make gce-pd-driver-windows

FROM ${BASE_IMAGE}
FROM mcr.microsoft.com/oss/kubernetes/windows-host-process-containers-base-image:v1.0.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks a lot for digging through it and to make it work.

LABEL description="PD CSI driver"

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

USER ContainerAdministrator
Expand Down
36 changes: 14 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,10 @@ STAGINGVERSION=${GCE_PD_CSI_STAGING_VERSION}
STAGINGIMAGE=${GCE_PD_CSI_STAGING_IMAGE}
DRIVERBINARY=gce-pd-csi-driver
DRIVERWINDOWSBINARY=${DRIVERBINARY}.exe
LTSC2019=10.0.17763 # version mapping found here: https://kubernetes.io/docs/concepts/windows/user-guide/#handling-multiple-windows-versions-in-the-same-cluster

DOCKER=DOCKER_CLI_EXPERIMENTAL=enabled docker

BASE_IMAGE_LTSC2019=mcr.microsoft.com/windows/servercore:ltsc2019
BASE_IMAGE_20H2=mcr.microsoft.com/windows/servercore:20H2

# Both arrays MUST be index aligned.
WINDOWS_IMAGE_TAGS=ltsc2019 20H2
WINDOWS_BASE_IMAGES=$(BASE_IMAGE_LTSC2019) $(BASE_IMAGE_20H2)

GCFLAGS=""
ifdef GCE_PD_CSI_DEBUG
GCFLAGS="all=-N -l"
Expand All @@ -55,26 +49,24 @@ build-container: require-GCE_PD_CSI_STAGING_IMAGE require-GCE_PD_CSI_STAGING_VER
--build-arg STAGINGVERSION=$(STAGINGVERSION) \
--push .

build-and-push-windows-container-ltsc2019: require-GCE_PD_CSI_STAGING_IMAGE init-buildx
$(DOCKER) buildx build --file=Dockerfile.Windows --platform=windows \
-t $(STAGINGIMAGE):$(STAGINGVERSION)_ltsc2019 \
--build-arg BASE_IMAGE=$(BASE_IMAGE_LTSC2019) \
--build-arg STAGINGVERSION=$(STAGINGVERSION) --push .
# TODO(alexander-ding): the Windows image built here should work on every Windows Server version
# however, due to https://github.com/containerd/containerd/issues/7431 we still need to tag
# a specific Windows OS version in the image. For now, we tag Windows ltsc2019, but after the issue
# is resolved, we can remove the docker manifest annotate lines and rename the manifest to $(STAGINGVERSION)_windows

build-and-push-windows-container-20H2: require-GCE_PD_CSI_STAGING_IMAGE init-buildx
$(DOCKER) buildx build --file=Dockerfile.Windows --platform=windows \
-t $(STAGINGIMAGE):$(STAGINGVERSION)_20H2 \
--build-arg BASE_IMAGE=$(BASE_IMAGE_20H2) \
build-and-push-container-windows-ltsc2019: require-GCE_PD_CSI_STAGING_IMAGE init-buildx
$(DOCKER) buildx build --file=Dockerfile.Windows --platform=windows/amd64 \
-t $(STAGINGIMAGE):$(STAGINGVERSION)_windows_ltsc2019 \
--build-arg STAGINGVERSION=$(STAGINGVERSION) --push .

build-and-push-multi-arch: build-and-push-container-linux-amd64 build-and-push-container-linux-arm64 build-and-push-windows-container-ltsc2019 build-and-push-windows-container-20H2
$(DOCKER) manifest create --amend $(STAGINGIMAGE):$(STAGINGVERSION) $(STAGINGIMAGE):$(STAGINGVERSION)_linux_amd64 $(STAGINGIMAGE):$(STAGINGVERSION)_linux_arm64 $(STAGINGIMAGE):$(STAGINGVERSION)_20H2 $(STAGINGIMAGE):$(STAGINGVERSION)_ltsc2019
STAGINGIMAGE="$(STAGINGIMAGE)" STAGINGVERSION="$(STAGINGVERSION)" WINDOWS_IMAGE_TAGS="$(WINDOWS_IMAGE_TAGS)" WINDOWS_BASE_IMAGES="$(WINDOWS_BASE_IMAGES)" ./manifest_osversion.sh
build-and-push-multi-arch: build-and-push-container-linux-amd64 build-and-push-container-linux-arm64 build-and-push-container-windows-ltsc2019
$(DOCKER) manifest create --amend $(STAGINGIMAGE):$(STAGINGVERSION) $(STAGINGIMAGE):$(STAGINGVERSION)_linux_amd64 $(STAGINGIMAGE):$(STAGINGVERSION)_linux_arm64 $(STAGINGIMAGE):$(STAGINGVERSION)_windows_ltsc2019
$(DOCKER) manifest annotate --os-version 10.0.17763 $(STAGINGIMAGE):$(STAGINGVERSION) $(STAGINGIMAGE):$(STAGINGVERSION)_windows_ltsc2019
alexander-ding marked this conversation as resolved.
Show resolved Hide resolved
$(DOCKER) manifest push -p $(STAGINGIMAGE):$(STAGINGVERSION)

build-and-push-multi-arch-debug: build-and-push-container-linux-debug build-and-push-windows-container-ltsc2019
$(DOCKER) manifest create --amend $(STAGINGIMAGE):$(STAGINGVERSION) $(STAGINGIMAGE):$(STAGINGVERSION)_linux $(STAGINGIMAGE):$(STAGINGVERSION)_ltsc2019
STAGINGIMAGE="$(STAGINGIMAGE)" STAGINGVERSION="$(STAGINGVERSION)" WINDOWS_IMAGE_TAGS="ltsc2019" WINDOWS_BASE_IMAGES="$(BASE_IMAGE_LTSC2019)" ./manifest_osversion.sh
build-and-push-multi-arch-debug: build-and-push-container-linux-debug build-and-push-container-windows-ltsc2019
$(DOCKER) manifest create --amend $(STAGINGIMAGE):$(STAGINGVERSION) $(STAGINGIMAGE):$(STAGINGVERSION)_linux $(STAGINGIMAGE):$(STAGINGVERSION)_windows_ltsc2019
$(DOCKER) manifest annotate --os-version $(LTSC2019) $(STAGINGIMAGE):$(STAGINGVERSION) $(STAGINGIMAGE):$(STAGINGVERSION)_windows_ltsc2019
$(DOCKER) manifest push -p $(STAGINGIMAGE):$(STAGINGVERSION)

push-container: build-container
Expand Down
1 change: 1 addition & 0 deletions deploy/kubernetes/overlays/dev/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ kind: Kustomization
patchesStrategicMerge:
- controller_always_pull.yaml
- node_always_pull.yaml
- windows_hostprocess.yaml
namespace: gce-pd-csi-driver
resources:
- ../../base/
Expand Down
40 changes: 40 additions & 0 deletions deploy/kubernetes/overlays/dev/windows_hostprocess.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
kind: DaemonSet
apiVersion: apps/v1
metadata:
name: csi-gce-pd-node-win
spec:
template:
spec:
hostNetwork: true
securityContext:
windowsOptions:
hostProcess: true
runAsUserName: "NT AUTHORITY\\SYSTEM"
containers:
- name: csi-driver-registrar
command:
- csi-node-driver-registrar.exe
args:
- --v=5
- --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
volumeMounts:
- name: registration-dir
mountPath: /registration
$patch: delete
- name: gce-pd-driver
command:
- gce-pd-csi-driver.exe
args:
- --v=5
- --endpoint=unix:/c:\var\lib\kubelet\plugins\pd.csi.storage.gke.io\csi.sock
- --run-controller-service=false
volumeMounts:
- $patch: replace
volumes:
- name: plugin-dir
hostPath:
path: /var/lib/kubelet/plugins/pd.csi.storage.gke.io
type: DirectoryOrCreate
- $patch: replace
1 change: 1 addition & 0 deletions deploy/kubernetes/overlays/noauth-debug/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ patchesStrategicMerge:
- noauth.yaml
- controller-overlay.yaml
- node-overlay.yaml
- windows_hostprocess.yaml
namespace: gce-pd-csi-driver
# To change the dev image, add something like the following.
# images:
Expand Down
40 changes: 40 additions & 0 deletions deploy/kubernetes/overlays/noauth-debug/windows_hostprocess.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
kind: DaemonSet
apiVersion: apps/v1
metadata:
name: csi-gce-pd-node-win
spec:
template:
spec:
hostNetwork: true
securityContext:
windowsOptions:
hostProcess: true
runAsUserName: "NT AUTHORITY\\SYSTEM"
containers:
- name: csi-driver-registrar
command:
- csi-node-driver-registrar.exe
args:
- --v=5
- --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
volumeMounts:
- name: registration-dir
mountPath: /registration
$patch: delete
- name: gce-pd-driver
command:
- gce-pd-csi-driver.exe
args:
- --v=5
- --endpoint=unix:/c:\var\lib\kubelet\plugins\pd.csi.storage.gke.io\csi.sock
- --run-controller-service=false
volumeMounts:
- $patch: replace
volumes:
- name: plugin-dir
hostPath:
path: /var/lib/kubelet/plugins/pd.csi.storage.gke.io
type: DirectoryOrCreate
- $patch: replace
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 @@ -2456,6 +2453,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
41 changes: 0 additions & 41 deletions manifest_osversion.sh

This file was deleted.

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 @@ -105,3 +106,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