Skip to content

Added arm64 targets for linux binaries #561

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

Merged
merged 1 commit into from
May 26, 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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
- docker
before_install:
- sudo apt-get -qq update
- sudo apt-get install -y libsystemd-dev
- sudo apt-get install -y libsystemd-dev libc6-dev-arm64-cross gcc-aarch64-linux-gnu
install:
- mkdir -p $HOME/gopath/src/k8s.io
- mv $TRAVIS_BUILD_DIR $HOME/gopath/src/k8s.io/node-problem-detector
Expand Down
31 changes: 27 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
all: build

# PLATFORMS is the set of OS_ARCH that NPD can build against.
PLATFORMS=linux_amd64 windows_amd64
LINUX_PLATFORMS=linux_amd64 linux_arm64
PLATFORMS=$(LINUX_PLATFORMS) windows_amd64

# VERSION is the version of the binary.
VERSION?=$(shell if [ -d .git ]; then echo `git describe --tags --dirty`; else echo "UNKNOWN"; fi)
Expand Down Expand Up @@ -123,7 +124,9 @@ ifeq ($(ENABLE_JOURNALD), 1)
BINARIES_LINUX_ONLY += bin/log-counter
endif

ALL_BINARIES = $(foreach binary, $(BINARIES) $(BINARIES_LINUX_ONLY), ./$(binary)) $(foreach binary, $(BINARIES) $(BINARIES_LINUX_ONLY), output/linux_amd64/$(binary)) $(foreach binary, $(BINARIES), output/windows_amd64/$(binary).exe)
ALL_BINARIES = $(foreach binary, $(BINARIES) $(BINARIES_LINUX_ONLY), ./$(binary)) \
$(foreach platform, $(LINUX_PLATFORMS), $(foreach binary, $(BINARIES) $(BINARIES_LINUX_ONLY), output/$(platform)/$(binary))) \
$(foreach binary, $(BINARIES), output/windows_amd64/$(binary).exe)
ALL_TARBALLS = $(foreach platform, $(PLATFORMS), $(NPD_NAME_VERSION)-$(platform).tar.gz)

output/windows_amd64/bin/%.exe: $(PKG_SOURCES)
Expand All @@ -143,7 +146,8 @@ output/windows_amd64/test/bin/%.exe: $(PKG_SOURCES)
./test/e2e/$(subst -,,$*)

output/linux_amd64/bin/%: $(PKG_SOURCES)
GOOS=linux GOARCH=amd64 CGO_ENABLED=$(CGO_ENABLED) GO111MODULE=on go build \
GOOS=linux GOARCH=amd64 CGO_ENABLED=$(CGO_ENABLED) GO111MODULE=on \
CC=x86_64-linux-gnu-gcc go build \
-mod vendor \
-o $@ \
-ldflags '-X $(PKG)/pkg/version.version=$(VERSION)' \
Expand All @@ -152,7 +156,26 @@ output/linux_amd64/bin/%: $(PKG_SOURCES)
touch $@

output/linux_amd64/test/bin/%: $(PKG_SOURCES)
GOOS=linux GOARCH=amd64 CGO_ENABLED=$(CGO_ENABLED) GO111MODULE=on go build \
GOOS=linux GOARCH=amd64 CGO_ENABLED=$(CGO_ENABLED) GO111MODULE=on \
CC=x86_64-linux-gnu-gcc go build \
-mod vendor \
-o $@ \
-tags "$(LINUX_BUILD_TAGS)" \
./test/e2e/$(subst -,,$*)

output/linux_arm64/bin/%: $(PKG_SOURCES)
GOOS=linux GOARCH=arm64 CGO_ENABLED=$(CGO_ENABLED) GO111MODULE=on \
CC=aarch64-linux-gnu-gcc go build \
-mod vendor \
-o $@ \
-ldflags '-X $(PKG)/pkg/version.version=$(VERSION)' \
-tags "$(LINUX_BUILD_TAGS)" \
./cmd/$(subst -,,$*)
touch $@

output/linux_arm64/test/bin/%: $(PKG_SOURCES)
GOOS=linux GOARCH=arm64 CGO_ENABLED=$(CGO_ENABLED) GO111MODULE=on \
CC=aarch64-linux-gnu-gcc go build \
-mod vendor \
-o $@ \
-tags "$(LINUX_BUILD_TAGS)" \
Expand Down
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,16 @@ For example, to run without auth, use the following config:

## Build Image

* Install development dependencies for `libsystemd` and the ARM GCC toolchain
* Debian: `apt install libsystemd-dev gcc-aarch64-linux-gnu`
* Ubuntu: `apt install libsystemd-journal-dev gcc-aarch64-linux-gnu`

* `go get` or `git clone` node-problem-detector repo into `$GOPATH/src/k8s.io` or `$GOROOT/src/k8s.io`
with one of the below directions:
* `cd $GOPATH/src/k8s.io && git clone [email protected]:kubernetes/node-problem-detector.git`
* `cd $GOPATH/src/k8s.io && go get k8s.io/node-problem-detector`

* run `make` in the top directory. It will:
* Run `make` in the top directory. It will:
* Build the binary.
* Build the docker image. The binary and `config/` are copied into the docker image.

Expand All @@ -158,11 +162,6 @@ and [System Stats Monitor](https://github.com/kubernetes/node-problem-detector/t
Check out the [Problem Daemon](https://github.com/kubernetes/node-problem-detector#problem-daemon) section
to see how to disable each problem daemon during compilation time.

**Note**:
By default, node-problem-detector will be built with systemd support with the `make` command. This requires systemd develop files.
You should download the systemd develop files first. For Ubuntu, the `libsystemd-journal-dev` package should
be installed. For Debian, the `libsystemd-dev` package should be installed.

## Push Image

`make push` uploads the docker image to a registry. By default, the image will be uploaded to
Expand Down Expand Up @@ -320,4 +319,4 @@ See [NPD e2e test documentation](https://github.com/kubernetes/node-problem-dete
* [Slides](https://docs.google.com/presentation/d/1bkJibjwWXy8YnB5fna6p-Ltiy-N5p01zUsA22wCNkXA/edit?usp=sharing)
* [Plugin Interface Proposal](https://docs.google.com/document/d/1jK_5YloSYtboj-DtfjmYKxfNnUxCAvohLnsH5aGCAYQ/edit#)
* [Addon Manifest](https://github.com/kubernetes/kubernetes/tree/master/cluster/addons/node-problem-detector)
* [Metrics Mode Proposal](https://docs.google.com/document/d/1SeaUz6kBavI283Dq8GBpoEUDrHA2a795xtw0OvjM568/edit)
* [Metrics Mode Proposal](https://docs.google.com/document/d/1SeaUz6kBavI283Dq8GBpoEUDrHA2a795xtw0OvjM568/edit)
2 changes: 1 addition & 1 deletion test/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function get-version() {

function install-lib() {
apt-get update
apt-get install -y libsystemd-dev
apt-get install -y libsystemd-dev gcc-aarch64-linux-gnu
# Turn off go modules here, because we are not trying to install
# ginkgo library/module. We are trying to install the ginkgo executable.
GO111MODULE=off go get -v github.com/onsi/ginkgo/ginkgo
Expand Down