Some Calico bits are built using the calico/go-build
arm64 container, which
includes Go 1.10.x. Others are built natively. The native builds assume
Go 1.8.7 is installed in $HOME/go-1.8.7/bin
with GOPATH=$HOME/go
:
mkdir -p $HOME/go/bin
mkdir -p $HOME/go-1.8.7
pushd $HOME/go-1.8.7
wget https://dl.google.com/go/go1.8.7.linux-arm64.tar.gz
tar zxf go1.8.7.linux-arm64.tar.gz
popd
## update ~/.bashrc: export GOPATH=$HOME/go
## update ~/.bashrc: export GOROOT=$HOME/go-1.8.7
## update ~/.bashrc: export PATH=$GOROOT/bin:$GOPATH/bin:$PATH
Glide installed in $GOPATH/bin
:
git clone --depth 1 --single-branch --branch master \
https://github.com/Masterminds/glide.git \
$GOPATH/src/github.com/Masterminds/glide
pushd $GOPATH/src/github.com/Masterminds/glide
## patch issue in 1.10 (used in containerized builds)
curl https://patch-diff.githubusercontent.com/raw/Masterminds/glide/pull/990.patch | \
git apply -v --index
## disable CGO so we get a static build
CGO_ENABLED=0 make build
cp -a glide $GOPATH/bin
popd
The calico subordinate charm needs a calico-arm64 resource. For v3.x, this is
simple because calico releases arm64 binaries that we can fetch. For v2.6, we
need to build and package these binaries ourselves. They must be built
natively, as cross-compiling isn’t a supported option until ~v3.0, and the
containers used in the recommended make
processes below aren't available for
arm64. ¯\_(ツ)_/¯:
https://github.com/projectcalico/calicoctl/blob/release-v2.6/README.md#building-calicoctl
The following procedure will result in a calicoctl binary in
$GOPATH/src/github.com/projectcalico/calicoctl/dist
:
git clone --depth 1 --single-branch --branch release-v2.6 \
https://github.com/projectcalico/calicoctl.git \
$GOPATH/src/github.com/projectcalico/calicoctl
pushd $GOPATH/src/github.com/projectcalico/calicoctl
glide install -strip-vendor
make binary ARCH=arm64
popd
The following procedure will result in calico/calico-ipam binaries in
$HOME/go/src/github.com/projectcalico/cni-plugin/dist
:
git clone --depth 1 --single-branch --branch release-v2.6 \
https://github.com/projectcalico/cni-plugin.git \
$GOPATH/src/github.com/projectcalico/cni-plugin
pushd $GOPATH/src/github.com/projectcalico/cni-plugin
glide install -strip-vendor
make binary ARCH=arm64
popd
Transfer the above calicoctl
, calico
, and calico-ipam
binaries to some
place accessible by the machine that will run charm push
, for example:
https://people.canonical.com/~kwmonroe/calico-2.6-arm64/
Clone, build, push, and release (adjust for your environment as needed):
rm -rf /tmp/layer-calico
git clone https://github.com/juju-solutions/layer-calico.git /tmp/layer-calico
pushd /tmp/layer-calico
## build first so the raw resources dont end up alongside the built artifact
charm build -r --no-local-layers
## verify correct URLs for the arm64 binaries before running the following
./build-calico-resource.sh
popd
cd $HOME/charms/builds/calico
charm proof
charm push . cs:~containers/calico \
--resource calico=/tmp/layer-calico/calico-amd64.tar.gz \
--resource calico-arm64=/tmp/layer-calico/calico-arm64.tar.gz
charm release cs:~containers/calico-XX -c edge \
--resource calico-Y \
--resource calico-arm64-Z
We need to build some images for arm64 because they're not being built by upstream for v2.6. All custom images can be found here:
https://hub.docker.com/u/cdkbot
This will all go away when we move to calico-v3.x, which releases arm64 images here:
https://quay.io/repository/calico/node?tab=tags
https://quay.io/repository/calico/kube-controllers?tab=tags
Until then, let's earn our keep. We'll start with the easy one.
This is built natively, though it looks like it could be cross compiled given
the right ARCH
and BUILD_ARCH
parameters:
git clone --depth 1 --single-branch --branch release-v2.6 \
https://github.com/projectcalico/kube-controllers.git \
$GOPATH/src/github.com/projectcalico/kube-controllers
pushd $GOPATH/src/github.com/projectcalico/kube-controllers
## Silly rabbits
sed -i -e 's/amd64/arm64/' Dockerfile.arm64
make image ARCH=arm64
docker tag calico/kube-controllers:latest-arm64 \
cdkbot/kube-controllers-arm64:v1.0.4
popd
This one is a beast, as it requires a bunch of calico components to be built first:
https://github.com/projectcalico/calico/blob/release-v2.6/BUILDING_CALICO.md
Grab a McCafe and get settled in. Then get some helpful envars exported (from https://docs.projectcalico.org/v2.6/releases/):
cat <<EOF > $HOME/calico-2.6-versions.sh
export VERSION_TYPHA=v0.5.7
export VERSION_FELIX=2.6.7
export VERSION_CNI=v1.11.6
export VERSION_CONFD=v0.12.1-calico-0.4.4
## NB: bird-0.3.2 cant build on arm (automake too old); go a little newer
export VERSION_BIRD=feature-ipinip
export VERSION_BGP_DAEMON=v0.2.2
export VERSION_LIBNETWORK=v1.1.3
export VERSION_CALICOCTL=v1.6.4
export VERSION_CALICO=v2.6.10
EOF
source $HOME/calico-2.6-versions.sh
export BASEDIR=~/go/src/github.com/projectcalico
Fetch:
mkdir $HOME/arm-calico
cd $HOME/arm-calico
git clone --depth 1 --single-branch --branch master \
https://github.com/projectcalico/docker-protobuf.git
pushd docker-protobuf
Build:
docker build --build-arg http_proxy=$http_proxy \
--build-arg https_proxy=$https_proxy \
-t cdkbot/docker-protobuf-arm64:v3.5.1 ./
popd
Fetch:
cd $BASEDIR
git clone --depth 1 --single-branch --branch $VERSION_FELIX \
https://github.com/projectcalico/felix.git
pushd felix
Modify (NB: protobuf 0.3.0 failed, so bump to 1.1.x per protocolbuffers/protobuf#4582):
diff --git a/Makefile b/Makefile
index 39c5f34..4fd052e 100644
--- a/Makefile
+++ b/Makefile
@@ -59,7 +59,8 @@ ifeq ($(ARCH),ppc64le)
GO_BUILD_VER:=latest
endif
-GO_BUILD_CONTAINER?=calico/go-build$(ARCHTAG):$(GO_BUILD_VER)
+GO_BUILD_VER:=v0.15
+GO_BUILD_CONTAINER?=calico/go-build:$(GO_BUILD_VER)
help:
@echo "Felix Makefile"
@@ -176,7 +177,7 @@ calico/felix: bin/calico-felix
rm -rf docker-image/bin
mkdir -p docker-image/bin
cp bin/calico-felix docker-image/bin/
- docker build --pull -t calico/felix$(ARCHTAG) --file ./docker-image/Dockerfile$(ARCHTAG) docker-image
+ docker build --build-arg http_proxy=$$http_proxy --build-arg https_proxy=$$https_proxy--pull -t calico/felix$(ARCHTAG) --file ./docker-image/Dockerfile$(ARCHTAG) docker-image
# Targets for Felix testing with the k8s backend and a k8s API server,
# with k8s model resources being injected by a separate test client.
@@ -249,6 +250,7 @@ DOCKER_GO_BUILD := mkdir -p .go-pkg-cache && \
-e LOCAL_USER_ID=$(MY_UID) \
-v $${PWD}:/go/src/github.com/projectcalico/felix:rw \
-v $${PWD}/.go-pkg-cache:/go/pkg:rw \
+ -v /home/ubuntu/.glide:/home/user/.glide:rw \
-w /go/src/github.com/projectcalico/felix \
$(GO_BUILD_CONTAINER)
@@ -280,7 +282,7 @@ protobuf: proto/felixbackend.pb.go
# Generate the protobuf bindings for go.
proto/felixbackend.pb.go: proto/felixbackend.proto
$(DOCKER_RUN_RM) -v $${PWD}/proto:/src:rw \
- calico/protoc$(ARCHTAG) \
+ cdkbot/docker-protobuf$(ARCHTAG):v3.5.1 \
--gogofaster_out=. \
felixbackend.proto
diff --git a/docker-image/Dockerfile b/docker-image/Dockerfile
index 96d5c40..9392c20 100644
--- a/docker-image/Dockerfile
+++ b/docker-image/Dockerfile
@@ -1,20 +1,10 @@
-FROM alpine:3.4
+FROM arm64v8/alpine:3.7
MAINTAINER Shaun Crampton <[email protected]>
# Since our binary isn't designed to run as PID 1, run it via the tini init daemon.
RUN apk --no-cache add --update tini
ENTRYPOINT ["/sbin/tini", "--"]
-# Download and install glibc in one layer
-RUN apk --no-cache add wget ca-certificates libgcc && \
- wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://raw.githubusercontent.com/sgerrand/alpine-pkg-glibc/master/sgerrand.rsa.pub && \
- wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.23-r3/glibc-2.23-r3.apk && \
- wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.23-r3/glibc-bin-2.23-r3.apk && \
- apk add glibc-2.23-r3.apk glibc-bin-2.23-r3.apk && \
- /usr/glibc-compat/sbin/ldconfig /lib /usr/glibc/usr/lib && \
- apk del wget && \
- rm -f glibc-2.23-r3.apk glibc-bin-2.23-r3.apk
-
# Install Felix's dependencies.
RUN apk --no-cache add ip6tables ipset iputils iproute2 conntrack-tools
diff --git a/glide.yaml b/glide.yaml
index cf02b99..8209632 100644
--- a/glide.yaml
+++ b/glide.yaml
@@ -36,7 +36,9 @@ import:
- package: github.com/prometheus/client_golang
version: ^0.8.0
- package: github.com/gogo/protobuf
- version: ^0.3.0
+ version: v1.1.1
+- package: github.com/golang/protobuf
+ version: v1.1.0
- package: github.com/vishvananda/netlink
- package: github.com/gavv/monotime
- package: github.com/onsi/ginkgo
@@ -60,6 +62,5 @@ import:
- net
- package: github.com/onsi/gomega
version: ^1.1.0
-- name: gopkg.in/yaml.v2
+- package: gopkg.in/yaml.v2
version: 53feefa2559fb8dfa8d81baad31be332c97d6c77
-
Build:
## we hijacked the Dockerfile; give it an arm64 suffix
cp -a docker-image/Dockerfile docker-image/Dockerfile-arm64
glide update # <- may have to rm -rf ~/.glide/cache/*/{golang|gogo}-protobuf
make calico/felix ARCH=arm64
docker tag calico/felix-arm64:latest cdkbot/felix-arm64:$VERSION_FELIX
popd
Fetch:
cd $BASEDIR
git clone --depth 1 --single-branch --branch $VERSION_CONFD \
https://github.com/projectcalico/confd.git
pushd confd
Modify:
diff --git a/Makefile b/Makefile
index 561f4a8..5e3a2ef 100644
--- a/Makefile
+++ b/Makefile
@@ -14,6 +14,8 @@ ifeq ($(ARCH),ppc64le)
GO_BUILD_VER?=latest
endif
+GO_BUILD_VER:=v0.15
+
# Disable make's implicit rules, which are not useful for golang, and slow down the build
# considerably.
.SUFFIXES:
@@ -48,6 +50,8 @@ DOCKER_GO_BUILD := mkdir -p .go-pkg-cache && \
-e LOCAL_USER_ID=$(MY_UID) \
-v ${CURDIR}:/go/src/github.com/kelseyhightower/confd:rw \
-v ${CURDIR}/.go-pkg-cache:/go/pkg:rw \
+ -v /home/ubuntu/.glide:/home/user/.glide:rw \
+ -v /home/ubuntu/go/bin:/home/user/bin:ro \
-w /go/src/github.com/kelseyhightower/confd \
$(GO_BUILD_CONTAINER)
@@ -65,7 +69,7 @@ update-vendor:
.PHONY: vendor
vendor vendor/.up-to-date: glide.lock
mkdir -p $$HOME/.glide
- $(DOCKER_GO_BUILD) glide install --strip-vendor
+ $(DOCKER_GO_BUILD) sh -c 'export PATH=/home/user/bin:$$PATH && glide install --strip-vendor'
touch vendor/.up-to-date
container: bin/confd
Build:
make bin/confd ARCH=arm64
popd
Fetch:
cd $BASEDIR
git clone --depth 1 --single-branch --branch $VERSION_BGP_DAEMON \
https://github.com/projectcalico/calico-bgp-daemon.git
pushd calico-bgp-daemon
Modify:
diff --git a/Dockerfile b/Dockerfile
index afa9033..09f8acd 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,4 @@
-FROM alpine:3.4
+FROM arm64v8/alpine:3.7
MAINTAINER Gunjan Patel <[email protected]>
diff --git a/Makefile b/Makefile
index eb25246..f05cafc 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
-CALICO_BUILD?=calico/go-build
+CALICO_BUILD?=calico/go-build:v0.15
SRC_FILES=$(shell find . -type f -name '*.go')
GOBGPD_VERSION?=$(shell git describe --tags --dirty)
CONTAINER_NAME?=calico/gobgpd
@@ -23,13 +23,13 @@ binary: dist/calico-bgp-daemon
dist/gobgp:
mkdir -p $(@D)
- docker run --rm -v $(CURDIR)/dist:/go/bin \
- -e LOCAL_USER_ID=$(LOCAL_USER_ID) \
- $(CALICO_BUILD) go get -v github.com/osrg/gobgp/gobgp
+ wget https://github.com/osrg/gobgp/releases/download/v1.33/gobgp_1.33_linux_arm64.tar.gz
+ tar -C dist -zxf gobgp_1.33_linux_arm64.tar.gz gobgp
+ tar -C dist -zxf gobgp_1.33_linux_arm64.tar.gz gobgpd
dist/calico-bgp-daemon: $(SRC_FILES) vendor
mkdir -p $(@D)
- go build -v -o dist/calico-bgp-daemon \
+ CGO_ENABLED=0 go build -v -o dist/calico-bgp-daemon \
-ldflags "-X main.VERSION=$(GOBGPD_VERSION) -s -w" main.go ipam.go
build-containerized: clean vendor dist/gobgp
Build:
make build-containerized ARCH=arm64
popd
Fetch:
cd $BASEDIR
git clone --depth 1 --single-branch --branch $VERSION_BIRD \
https://github.com/projectcalico/bird.git
pushd bird
Modify:
diff --git a/build.sh b/build.sh
index aed14d9..730918d 100755
--- a/build.sh
+++ b/build.sh
@@ -67,7 +67,7 @@ fi
DIST=dist/
OBJ=obj/
-docker build -t $IMAGE -f builder-images/$DOCKERFILE .
+docker build --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy -t $IMAGE -f builder-images/$DOCKERFILE .
mkdir -p $DIST
# create_binaries expects:
# ARCH = architecture on which I am running
Build:
ARCH=arm64 ./build.sh
popd
Fetch:
cd $BASEDIR
git clone --depth 1 --single-branch --branch $VERSION_LIBNETWORK \
https://github.com/projectcalico/libnetwork-plugin.git
pushd libnetwork-plugin
Modify:
diff --git a/Dockerfile b/Dockerfile
index a13e92f..a8690b2 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,5 +1,5 @@
-FROM alpine
+FROM arm64v8/alpine:3.7
MAINTAINER Tom Denham <[email protected]>
-ADD dist/amd64/libnetwork-plugin /libnetwork-plugin
+ADD dist/arm64/libnetwork-plugin /libnetwork-plugin
ENTRYPOINT ["/libnetwork-plugin"]
diff --git a/Makefile b/Makefile
index c52fcad..870904a 100644
--- a/Makefile
+++ b/Makefile
@@ -17,6 +17,12 @@ ifeq ($(ARCH),ppc64le)
DIND_IMAGE?=ppc64le/docker:dind
endif
+ifeq ($(ARCH),arm64)
+ ARCHTAG:=-arm64
+ GO_BUILD_VER?=v0.15
+ BUSYBOX_IMAGE?=arm64v8/busybox:latest
+endif
+
# Disable make's implicit rules, which are not useful for golang, and slow down the build
# considerably.
.SUFFIXES:
@@ -29,7 +35,7 @@ LOCAL_IP_ENV?=$(shell ip route get 8.8.8.8 | head -1 | awk '{print $$7}')
# Can choose different docker versions see list here - https://hub.docker.com/_/docker/
HOST_CHECKOUT_DIR?=$(CURDIR)
CONTAINER_NAME?=calico/libnetwork-plugin$(ARCHTAG)
-GO_BUILD_CONTAINER?=calico/go-build$(ARCHTAG):$(GO_BUILD_VER)
+GO_BUILD_CONTAINER?=calico/go-build:$(GO_BUILD_VER)
DIST=dist/$(ARCH)
PLUGIN_LOCATION?=$(CURDIR)/$(DIST)/libnetwork-plugin
DOCKER_BINARY_CONTAINER?=docker-binary-container$(ARCHTAG)
@@ -63,6 +69,7 @@ $(DIST)/libnetwork-plugin: vendor
-v $(CURDIR):/go/src/github.com/projectcalico/libnetwork-plugin:ro \
-v $(CURDIR)/$(DIST):/go/src/github.com/projectcalico/libnetwork-plugin/$(DIST) \
-v $(CURDIR)/.go-pkg-cache:/go/pkg/:rw \
+ -v $(HOME)/.glide:/home/user/.glide:rw \
-e LOCAL_USER_ID=$(LOCAL_USER_ID) \
-e ARCH=$(ARCH) \
$(GO_BUILD_CONTAINER) sh -c '\
Build:
cp -a Dockerfile Dockerfile-arm64
glide update
make calico/libnetwork-plugin-arm64 ARCH=arm64
popd
Fetch:
cd $BASEDIR
git clone --depth 1 --single-branch --branch $VERSION_CALICO \
https://github.com/projectcalico/calico.git
pushd calico/calico_node
mkdir -p filesystem/bin
pushd filesystem/bin
cp $BASEDIR/confd/bin/confd .
cp $BASEDIR/bird/dist/arm64/* .
cp $BASEDIR/felix/bin/calico-felix .
cp $BASEDIR/calico-bgp-daemon/dist/* .
cp $BASEDIR/libnetwork-plugin/dist/arm64/libnetwork-plugin .
popd
Modify:
diff --git a/calico_node/Dockerfile b/calico_node/Dockerfile
index 9720e5e..1ac5b8c 100644
--- a/calico_node/Dockerfile
+++ b/calico_node/Dockerfile
@@ -11,22 +11,12 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-FROM alpine
+FROM arm64v8/alpine:3.7
MAINTAINER Tom Denham <[email protected]>
# Set the minimum Docker API version required for libnetwork.
ENV DOCKER_API_VERSION 1.21
-# Download and install glibc for use by non-static binaries that require it.
-RUN apk --no-cache add wget ca-certificates libgcc && \
- wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://raw.githubusercontent.com/sgerrand/alpine-pkg-glibc/master/sgerrand.rsa.pub && \
- wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.23-r3/glibc-2.23-r3.apk && \
- wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.23-r3/glibc-bin-2.23-r3.apk && \
- apk add glibc-2.23-r3.apk glibc-bin-2.23-r3.apk && \
- /usr/glibc-compat/sbin/ldconfig /lib /usr/glibc/usr/lib && \
- apk del wget && \
- rm -f glibc-2.23-r3.apk glibc-bin-2.23-r3.apk
-
# Install runit from the community repository, as its not yet available in global
RUN apk add --no-cache --repository "http://alpine.gliderlabs.com/alpine/edge/community" runit
diff --git a/calico_node/Makefile b/calico_node/Makefile
index 4ab6b1b..2d1e045 100644
--- a/calico_node/Makefile
+++ b/calico_node/Makefile
@@ -4,7 +4,7 @@ RELEASE_STREAM ?= v2.6
CI_RELEASE_STREAM ?= master
###############################################################################
-GO_BUILD_VER?=v0.8
+GO_BUILD_VER?=v0.15
CALICO_BUILD?=calico/go-build:$(GO_BUILD_VER)
CALICO_NODE_DIR=$(dir $(realpath $(lastword $(MAKEFILE_LIST))))
@@ -83,7 +83,7 @@ NODE_CONTAINER_NAME?=calico/node
NODE_CONTAINER_FILES=$(shell find $(NODE_CONTAINER_DIR)/filesystem -type f)
NODE_CONTAINER_CREATED=$(NODE_CONTAINER_DIR)/.calico_node.created
NODE_CONTAINER_BIN_DIR=$(NODE_CONTAINER_DIR)/filesystem/bin
-NODE_CONTAINER_BINARIES=startup allocate-ipip-addr calico-felix bird calico-bgp-daemon confd libnetwork-plugin
+NODE_CONTAINER_BINARIES=startup allocate-ipip-addr
FELIX_REPO?=calico/felix
FELIX_CONTAINER_NAME?=$(FELIX_REPO):$(FELIX_VER)
CONFD_REPO?=calico/confd
@@ -170,7 +170,7 @@ calico-node-latest.aci: calico-node.tar
# Build calico/node docker image - explicitly depend on the container binaries.
$(NODE_CONTAINER_CREATED): $(NODE_CONTAINER_DIR)/Dockerfile $(NODE_CONTAINER_FILES) $(addprefix $(NODE_CONTAINER_BIN_DIR)/,$(NODE_CONTAINER_BINARIES))
- docker build --pull -t $(NODE_CONTAINER_NAME) $(NODE_CONTAINER_DIR)
+ docker build --build-arg http_proxy=$$http_proxy --build-arg https_proxy=$$https_proxy --pull -t $(NODE_CONTAINER_NAME) $(NODE_CONTAINER_DIR)
touch $@
# Get felix binaries
@@ -238,7 +238,7 @@ $(NODE_CONTAINER_BIN_DIR)/allocate-ipip-addr: dist/allocate-ipip-addr
## Build startup.go
.PHONY: startup
startup:
- GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -v -i -o dist/startup $(LDFLAGS) startup/startup.go
+ GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -v -i -o dist/startup $(LDFLAGS) startup/startup.go
dist/startup: $(STARTUP_FILES) vendor
mkdir -p dist
@@ -257,7 +257,7 @@ dist/startup: $(STARTUP_FILES) vendor
## Build allocate_ipip_addr.go
.PHONY: allocate-ipip-addr
allocate-ipip-addr:
- GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -v -i -o dist/allocate-ipip-addr $(LDFLAGS) allocateipip/allocate_ipip_addr.go
+ GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -v -i -o dist/allocate-ipip-addr $(LDFLAGS) allocateipip/allocate_ipip_addr.go
dist/allocate-ipip-addr: $(ALLOCATE_IPIP_FILES) vendor
mkdir -p dist
Build:
make calico/node ARCH=arm64
docker tag calico/node:latest cdkbot/node-arm64:$VERSION_CALICO
popd
Deploy a CDK/calico cluster and set config like this:
juju config calico \
calico-node-image=cdkbot/node-arm64:v2.6.10 \
calico-policy-image=cdkbot/kube-controllers-arm64:v1.0.4
Can you share the final calico/node v2.6 image on arm64, thanks