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

fix: arm64 container build issue #257

Merged
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
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/csi-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions pkg/smbplugin/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
6 changes: 4 additions & 2 deletions pkg/smbplugin/Windows.Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
3 changes: 2 additions & 1 deletion pkg/smbplugin/dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
7 changes: 6 additions & 1 deletion test/integration/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions test/sanity/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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...'
Expand Down