Skip to content

Commit 9ce0dbf

Browse files
authored
Merge pull request #561 from pwschuurman/arm64-support
Added arm64 targets for linux binaries
2 parents f27c3a8 + bd2a900 commit 9ce0dbf

File tree

4 files changed

+35
-13
lines changed

4 files changed

+35
-13
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ services:
1212
- docker
1313
before_install:
1414
- sudo apt-get -qq update
15-
- sudo apt-get install -y libsystemd-dev
15+
- sudo apt-get install -y libsystemd-dev libc6-dev-arm64-cross gcc-aarch64-linux-gnu
1616
install:
1717
- mkdir -p $HOME/gopath/src/k8s.io
1818
- mv $TRAVIS_BUILD_DIR $HOME/gopath/src/k8s.io/node-problem-detector

Makefile

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
all: build
2323

2424
# PLATFORMS is the set of OS_ARCH that NPD can build against.
25-
PLATFORMS=linux_amd64 windows_amd64
25+
LINUX_PLATFORMS=linux_amd64 linux_arm64
26+
PLATFORMS=$(LINUX_PLATFORMS) windows_amd64
2627

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

126-
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)
127+
ALL_BINARIES = $(foreach binary, $(BINARIES) $(BINARIES_LINUX_ONLY), ./$(binary)) \
128+
$(foreach platform, $(LINUX_PLATFORMS), $(foreach binary, $(BINARIES) $(BINARIES_LINUX_ONLY), output/$(platform)/$(binary))) \
129+
$(foreach binary, $(BINARIES), output/windows_amd64/$(binary).exe)
127130
ALL_TARBALLS = $(foreach platform, $(PLATFORMS), $(NPD_NAME_VERSION)-$(platform).tar.gz)
128131

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

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

154158
output/linux_amd64/test/bin/%: $(PKG_SOURCES)
155-
GOOS=linux GOARCH=amd64 CGO_ENABLED=$(CGO_ENABLED) GO111MODULE=on go build \
159+
GOOS=linux GOARCH=amd64 CGO_ENABLED=$(CGO_ENABLED) GO111MODULE=on \
160+
CC=x86_64-linux-gnu-gcc go build \
161+
-mod vendor \
162+
-o $@ \
163+
-tags "$(LINUX_BUILD_TAGS)" \
164+
./test/e2e/$(subst -,,$*)
165+
166+
output/linux_arm64/bin/%: $(PKG_SOURCES)
167+
GOOS=linux GOARCH=arm64 CGO_ENABLED=$(CGO_ENABLED) GO111MODULE=on \
168+
CC=aarch64-linux-gnu-gcc go build \
169+
-mod vendor \
170+
-o $@ \
171+
-ldflags '-X $(PKG)/pkg/version.version=$(VERSION)' \
172+
-tags "$(LINUX_BUILD_TAGS)" \
173+
./cmd/$(subst -,,$*)
174+
touch $@
175+
176+
output/linux_arm64/test/bin/%: $(PKG_SOURCES)
177+
GOOS=linux GOARCH=arm64 CGO_ENABLED=$(CGO_ENABLED) GO111MODULE=on \
178+
CC=aarch64-linux-gnu-gcc go build \
156179
-mod vendor \
157180
-o $@ \
158181
-tags "$(LINUX_BUILD_TAGS)" \

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,16 @@ For example, to run without auth, use the following config:
137137

138138
## Build Image
139139

140+
* Install development dependencies for `libsystemd` and the ARM GCC toolchain
141+
* Debian: `apt install libsystemd-dev gcc-aarch64-linux-gnu`
142+
* Ubuntu: `apt install libsystemd-journal-dev gcc-aarch64-linux-gnu`
143+
140144
* `go get` or `git clone` node-problem-detector repo into `$GOPATH/src/k8s.io` or `$GOROOT/src/k8s.io`
141145
with one of the below directions:
142146
* `cd $GOPATH/src/k8s.io && git clone [email protected]:kubernetes/node-problem-detector.git`
143147
* `cd $GOPATH/src/k8s.io && go get k8s.io/node-problem-detector`
144148

145-
* run `make` in the top directory. It will:
149+
* Run `make` in the top directory. It will:
146150
* Build the binary.
147151
* Build the docker image. The binary and `config/` are copied into the docker image.
148152

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

161-
**Note**:
162-
By default, node-problem-detector will be built with systemd support with the `make` command. This requires systemd develop files.
163-
You should download the systemd develop files first. For Ubuntu, the `libsystemd-journal-dev` package should
164-
be installed. For Debian, the `libsystemd-dev` package should be installed.
165-
166165
## Push Image
167166

168167
`make push` uploads the docker image to a registry. By default, the image will be uploaded to
@@ -320,4 +319,4 @@ See [NPD e2e test documentation](https://github.com/kubernetes/node-problem-dete
320319
* [Slides](https://docs.google.com/presentation/d/1bkJibjwWXy8YnB5fna6p-Ltiy-N5p01zUsA22wCNkXA/edit?usp=sharing)
321320
* [Plugin Interface Proposal](https://docs.google.com/document/d/1jK_5YloSYtboj-DtfjmYKxfNnUxCAvohLnsH5aGCAYQ/edit#)
322321
* [Addon Manifest](https://github.com/kubernetes/kubernetes/tree/master/cluster/addons/node-problem-detector)
323-
* [Metrics Mode Proposal](https://docs.google.com/document/d/1SeaUz6kBavI283Dq8GBpoEUDrHA2a795xtw0OvjM568/edit)
322+
* [Metrics Mode Proposal](https://docs.google.com/document/d/1SeaUz6kBavI283Dq8GBpoEUDrHA2a795xtw0OvjM568/edit)

test/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function get-version() {
6565

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

0 commit comments

Comments
 (0)