diff --git a/Makefile b/Makefile index 54ec0f4cf..dae7a66aa 100644 --- a/Makefile +++ b/Makefile @@ -117,15 +117,15 @@ e2e-teardown: .PHONY: smb smb: - CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) go build -a -ldflags ${LDFLAGS} -mod vendor -o _output/smbplugin ./pkg/smbplugin + CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) go build -a -ldflags ${LDFLAGS} -mod vendor -o _output/${ARCH}/smbplugin ./pkg/smbplugin .PHONY: smb-windows smb-windows: - CGO_ENABLED=0 GOOS=windows go build -a -ldflags ${LDFLAGS} -mod vendor -o _output/smbplugin.exe ./pkg/smbplugin + CGO_ENABLED=0 GOOS=windows go build -a -ldflags ${LDFLAGS} -mod vendor -o _output/${ARCH}/smbplugin.exe ./pkg/smbplugin .PHONY: smb-darwin smb-darwin: - CGO_ENABLED=0 GOOS=darwin go build -a -ldflags ${LDFLAGS} -mod vendor -o _output/smbplugin ./pkg/smbplugin + CGO_ENABLED=0 GOOS=darwin go build -a -ldflags ${LDFLAGS} -mod vendor -o _output/${ARCH}/smbplugin ./pkg/smbplugin .PHONY: container container: smb @@ -139,7 +139,8 @@ container-linux: .PHONY: container-windows container-windows: docker buildx build --pull --output=type=$(OUTPUT_TYPE) --platform="windows/$(ARCH)" \ - -t $(IMAGE_TAG)-windows-$(OSVERSION)-$(ARCH) --build-arg OSVERSION=$(OSVERSION) -f ./pkg/smbplugin/Windows.Dockerfile . + -t $(IMAGE_TAG)-windows-$(OSVERSION)-$(ARCH) --build-arg OSVERSION=$(OSVERSION) \ + --build-arg ARCH=$(ARCH) -f ./pkg/smbplugin/Windows.Dockerfile . .PHONY: container-all container-all: smb-windows diff --git a/docs/csi-dev.md b/docs/csi-dev.md index 61c1a5453..0b848a739 100644 --- a/docs/csi-dev.md +++ b/docs/csi-dev.md @@ -37,7 +37,7 @@ $ make build #### Start CSI driver locally ```console $ cd $GOPATH/src/github.com/kubernetes-csi/csi-driver-smb -$ ./_output/smbplugin --endpoint tcp://127.0.0.1:10000 --nodeid CSINode -v=5 & +$ ./_output/amd64/smbplugin --endpoint tcp://127.0.0.1:10000 --nodeid CSINode -v=5 & ``` #### 1. Get plugin info diff --git a/pkg/smbplugin/Dockerfile b/pkg/smbplugin/Dockerfile index 76902026e..afdec3dc5 100644 --- a/pkg/smbplugin/Dockerfile +++ b/pkg/smbplugin/Dockerfile @@ -12,15 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -ARG LDFLAGS ARG ARCH FROM k8s.gcr.io/build-image/debian-base-${ARCH}:v2.1.3 -COPY ./_output/smbplugin /smbplugin RUN clean-install ca-certificates cifs-utils util-linux e2fsprogs mount udev xfsprogs LABEL maintainers="andyzhangx" LABEL description="SMB CSI Driver" +ARG ARCH -COPY ./_output/smbplugin /smbplugin +COPY ./_output/${ARCH}/smbplugin /smbplugin ENTRYPOINT ["/smbplugin"] diff --git a/pkg/smbplugin/Windows.Dockerfile b/pkg/smbplugin/Windows.Dockerfile index 8f05e3c9c..bcdc26182 100644 --- a/pkg/smbplugin/Windows.Dockerfile +++ b/pkg/smbplugin/Windows.Dockerfile @@ -1,10 +1,12 @@ ARG OSVERSION -FROM --platform=linux/amd64 gcr.io/k8s-staging-e2e-test-images/windows-servercore-cache:1.0-linux-amd64-${OSVERSION} as core +ARG ARCH=amd64 +FROM --platform=linux/${ARCH} gcr.io/k8s-staging-e2e-test-images/windows-servercore-cache:1.0-linux-${ARCH}-${OSVERSION} as core FROM mcr.microsoft.com/windows/nanoserver:${OSVERSION} LABEL description="CSI SMB plugin" -COPY ./_output/smbplugin.exe /smbplugin.exe +ARG ARCH=amd64 +COPY ./_output/${ARCH}/smbplugin.exe /smbplugin.exe COPY --from=core /Windows/System32/netapi32.dll /Windows/System32/netapi32.dll USER ContainerAdministrator ENTRYPOINT ["/smbplugin.exe"] diff --git a/pkg/smbplugin/dev.Dockerfile b/pkg/smbplugin/dev.Dockerfile index 6978e0bb7..954a7391e 100644 --- a/pkg/smbplugin/dev.Dockerfile +++ b/pkg/smbplugin/dev.Dockerfile @@ -17,5 +17,6 @@ RUN apt-get update && apt-get install -y ca-certificates cifs-utils util-linux e LABEL maintainers="andyzhangx" LABEL description="SMB CSI Driver" -COPY ./_output/smbplugin /smbplugin +ARG ARCH=amd64 +COPY ./_output/${ARCH}/smbplugin /smbplugin ENTRYPOINT ["/smbplugin"] diff --git a/test/integration/run-test.sh b/test/integration/run-test.sh index c5521cd59..bf73ceda8 100755 --- a/test/integration/run-test.sh +++ b/test/integration/run-test.sh @@ -43,8 +43,13 @@ target_path='/tmp/targetpath' echo "Begin to run integration test ..." +ARCH=$(uname -p) +if [[ "${ARCH}" == "x86_64" || ${ARCH} == "unknown" ]]; then + ARCH="amd64" +fi + # Run CSI driver as a background service -_output/smbplugin --endpoint "$endpoint" --nodeid CSINode -v=5 & +_output/${ARCH}/smbplugin --endpoint "$endpoint" --nodeid CSINode -v=5 & trap cleanup EXIT sleep 5 diff --git a/test/sanity/run-test.sh b/test/sanity/run-test.sh index 330c08eec..2eccd4449 100755 --- a/test/sanity/run-test.sh +++ b/test/sanity/run-test.sh @@ -63,13 +63,18 @@ if [[ "$#" -gt 0 ]] && [[ -n "$1" ]]; then nodeid="$1" fi +ARCH=$(uname -p) +if [[ "${ARCH}" == "x86_64" || ${ARCH} == "unknown" ]]; then + ARCH="amd64" +fi + if [ -z "$GITHUB_ACTIONS" ] then # if not running on github actions, do not use sudo - _output/smbplugin --endpoint "$endpoint" --nodeid "$nodeid" -v=5 & + _output/${ARCH}/smbplugin --endpoint "$endpoint" --nodeid "$nodeid" -v=5 & else # if running on github actions, use sudo - sudo _output/smbplugin --endpoint "$endpoint" --nodeid "$nodeid" -v=5 & + sudo _output/${ARCH}/smbplugin --endpoint "$endpoint" --nodeid "$nodeid" -v=5 & fi echo 'Begin to run sanity test...'