Skip to content

Commit

Permalink
Merge pull request #23931 from luxas/build_for_arm64
Browse files Browse the repository at this point in the history
Build Kubernetes, etcd and flannel for arm64 and ppc64le
  • Loading branch information
lavalamp committed Apr 14, 2016
2 parents 5cc7c95 + 4559a84 commit 4389aa1
Show file tree
Hide file tree
Showing 15 changed files with 134 additions and 114 deletions.
7 changes: 5 additions & 2 deletions build/build-image/cross/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ FROM golang:1.6.0

ENV GOARM 6
ENV KUBE_DYNAMIC_CROSSPLATFORMS \
armel
armel \
arm64 \
ppc64el

ENV KUBE_CROSSPLATFORMS \
linux/386 \
linux/arm \
linux/arm linux/arm64 \
linux/ppc64le \
darwin/amd64 darwin/386 \
windows/amd64 windows/386

Expand Down
4 changes: 2 additions & 2 deletions build/build-image/cross/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ TAG = $(shell cat VERSION)
build:
docker build -t gcr.io/google_containers/$(IMAGE):$(TAG) .

push: build
push: build
gcloud docker --server=gcr.io push gcr.io/google_containers/$(IMAGE):$(TAG)

all: push
all: push
2 changes: 1 addition & 1 deletion build/build-image/cross/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.6.0-1
v1.6.0-2
14 changes: 5 additions & 9 deletions build/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ readonly KUBE_GCS_DELETE_EXISTING="${KUBE_GCS_DELETE_EXISTING:-n}"

# Constants
readonly KUBE_BUILD_IMAGE_REPO=kube-build
readonly KUBE_BUILD_IMAGE_CROSS_TAG="v1.6.0-1"
readonly KUBE_BUILD_IMAGE_CROSS_TAG="v1.6.0-2"
# KUBE_BUILD_DATA_CONTAINER_NAME=kube-build-data-<hash>"

# Here we map the output directories across both the local and remote _output
Expand Down Expand Up @@ -672,9 +672,8 @@ function kube::release::clean_cruft() {
function kube::release::package_hyperkube() {
# If we have these variables set then we want to build all docker images.
if [[ -n "${KUBE_DOCKER_IMAGE_TAG-}" && -n "${KUBE_DOCKER_REGISTRY-}" ]]; then
for platform in "${KUBE_SERVER_PLATFORMS[@]}"; do
for arch in "${KUBE_SERVER_PLATFORMS[@]##*/}"; do

local arch=${platform##*/}
kube::log::status "Building hyperkube image for arch: ${arch}"
REGISTRY="${KUBE_DOCKER_REGISTRY}" VERSION="${KUBE_DOCKER_IMAGE_TAG}" ARCH="${arch}" make -C cluster/images/hyperkube/ build
done
Expand Down Expand Up @@ -1515,6 +1514,7 @@ function kube::release::gcs::publish() {
# Globals:
# KUBE_DOCKER_REGISTRY
# KUBE_DOCKER_IMAGE_TAG
# KUBE_SERVER_PLATFORMS
# Returns:
# If new pushing docker images was successful.
function kube::release::docker::release() {
Expand All @@ -1526,11 +1526,6 @@ function kube::release::docker::release() {
"hyperkube"
)

local archs=(
"amd64"
"arm"
)

local docker_push_cmd=("${DOCKER[@]}")
if [[ "${KUBE_DOCKER_REGISTRY}" == "gcr.io/"* ]]; then
docker_push_cmd=("gcloud" "docker")
Expand All @@ -1540,7 +1535,8 @@ function kube::release::docker::release() {
# Activate credentials for the k8s.production.user@gmail.com
gcloud config set account k8s.production.user@gmail.com
fi
for arch in "${archs[@]}"; do

for arch in "${KUBE_SERVER_PLATFORMS[@]##*/}"; do
for binary in "${binaries[@]}"; do

local docker_target="${KUBE_DOCKER_REGISTRY}/${binary}-${arch}:${KUBE_DOCKER_IMAGE_TAG}"
Expand Down
6 changes: 3 additions & 3 deletions cluster/images/etcd/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

FROM BASEIMAGE
MAINTAINER Dawn Chen <dawnchen@google.com>
MAINTAINER Dawn Chen <dawnchen@google.com>

COPY ./etcd /usr/local/bin/etcd
COPY ./etcdctl /usr/local/bin/etcdctl
COPY etcd /usr/local/bin/
COPY etcdctl /usr/local/bin/
50 changes: 31 additions & 19 deletions cluster/images/etcd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,57 @@
# Usage:
# [TAG=2.2.1] [REGISTRY=gcr.io/google_containers] [ARCH=amd64] [BASEIMAGE=busybox] make (build|push)

TAG?=2.2.1
TAG?=2.2.5
ARCH?=amd64
REGISTRY?=gcr.io/google_containers
GOLANG_VERSION?=1.6.0
GOARM=6
TEMP_DIR:=$(shell mktemp -d)

# Default base images for different architectures
# '/' in images has to be written as '\\/'
ifeq ($(ARCH),amd64)
BASEIMAGE?=busybox
endif
ifeq ($(ARCH),arm)
BASEIMAGE?=hypriot\\/armhf-busybox
BASEIMAGE?=armel/busybox
endif
ifeq ($(ARCH),arm64)
BASEIMAGE?=aarch64/busybox
endif
ifeq ($(ARCH),ppc64le)
BASEIMAGE?=ppc64le/busybox
endif

build:
# Download etcd source in a golang container and cross-compile it statically
# or download official binaries if the ARCH is amd64
./build-etcd.sh ${TAG} ${ARCH} ${TEMP_DIR}

# Copy the content in this dir to the temp dir
cp ./* ${TEMP_DIR}
cp ./* $(TEMP_DIR)

ifeq ($(ARCH),amd64)

# Do not compile if we should make an image for amd64, use the official etcd binaries instead
curl -sSL --retry 5 https://github.com/coreos/etcd/releases/download/v$(TAG)/etcd-v$(TAG)-linux-amd64.tar.gz | tar -xz -C $(TEMP_DIR) --strip-components=1
else

# Download etcd in a golang container and cross-compile it statically
docker run -it -v $(TEMP_DIR):/etcdbin golang:$(GOLANG_VERSION) /bin/bash -c \
"git clone https://github.com/coreos/etcd \
&& cd etcd && git checkout v$(TAG) \
&& GOARM=$(GOARM) GOARCH=$(ARCH) ./build \
&& cp bin/* /etcdbin"
endif

# Replace BASEIMAGE with the real base image
cd ${TEMP_DIR} && sed -i "s/BASEIMAGE/${BASEIMAGE}/g" Dockerfile
cd $(TEMP_DIR) && sed -i "s|BASEIMAGE|$(BASEIMAGE)|g" Dockerfile

# And build the image
docker build -t ${REGISTRY}/etcd-${ARCH}:${TAG} ${TEMP_DIR}

ifeq ($(ARCH),amd64)
# Backward compatibility. TODO: deprecate this image tag
docker tag -f ${REGISTRY}/etcd-${ARCH}:${TAG} ${REGISTRY}/etcd:${TAG}
endif
docker build -t $(REGISTRY)/etcd-$(ARCH):$(TAG) $(TEMP_DIR)

push: build
gcloud docker push ${REGISTRY}/etcd-${ARCH}:${TAG}
gcloud docker push $(REGISTRY)/etcd-$(ARCH):$(TAG)

# Backward compatibility. TODO: deprecate this image tag
ifeq ($(ARCH),amd64)
gcloud docker push ${REGISTRY}/etcd:${TAG}
# Backward compatibility. TODO: deprecate this image tag
docker tag -f $(REGISTRY)/etcd-$(ARCH):$(TAG) $(REGISTRY)/etcd:$(TAG)
gcloud docker push $(REGISTRY)/etcd:$(TAG)
endif

all: build
Expand Down
29 changes: 29 additions & 0 deletions cluster/images/etcd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
### etcd

This is a small etcd image used in Kubernetes setups where `etcd` is deployed as a docker image.

For `amd64`, official `etcd` and `etcdctl` binaries are downloaded from Github to maintain official support.
For other architectures, `etcd` is cross-compiled from source. Arch-specific `busybox` images serve as base images.

#### How to release

```console
# Build for linux/amd64 (default)
$ make push ARCH=amd64
# ---> gcr.io/google_containers/etcd-amd64:TAG
# ---> gcr.io/google_containers/etcd:TAG

$ make push ARCH=arm
# ---> gcr.io/google_containers/etcd-arm:TAG

$ make push ARCH=arm64
# ---> gcr.io/google_containers/etcd-arm64:TAG

$ make push ARCH=ppc64le
# ---> gcr.io/google_containers/etcd-ppc64le:TAG
```

If you don't want to push the images, run `make` or `make build` instead


[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/cluster/images/etcd/README.md?pixel)]()
57 changes: 0 additions & 57 deletions cluster/images/etcd/build-etcd.sh

This file was deleted.

14 changes: 10 additions & 4 deletions cluster/images/flannel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,24 @@
TAG?=0.5.5
ARCH?=amd64
REGISTRY?=gcr.io/google_containers
KUBE_CROSS_TAG=v1.4.2-1
KUBE_CROSS_TAG=v1.6.0-2
GOARM=6
TEMP_DIR:=$(shell mktemp -d)
BASEIMAGE?=gcr.io/google_containers/debian-iptables-${ARCH}:v2

ifeq ($(ARCH),arm)
CC=arm-linux-gnueabi-gcc
endif
ifeq ($(ARCH),arm64)
CC=aarch64-linux-gnu-gcc
endif
ifeq ($(ARCH),ppc64le)
CC=powerpc64le-linux-gnu-gcc
endif

build:
ifeq ($(ARCH),amd64)
# If we should build an amd64 flannel, go with the official one
# If we should build an amd64 flannel image, go with the official one
docker pull quay.io/coreos/flannel:$(TAG)

docker tag -f quay.io/coreos/flannel:$(TAG) $(REGISTRY)/flannel-$(ARCH):$(TAG)
Expand All @@ -40,8 +46,8 @@ else
cp ./* $(TEMP_DIR)

docker run -it -v $(TEMP_DIR):/flannel/bin gcr.io/google_containers/kube-cross:$(KUBE_CROSS_TAG) /bin/bash -c \
"curl -sSL https://github.com/coreos/flannel/archive/v${TAG}.tar.gz | tar -C /flannel -xz --strip-components=1 \
&& cd /flannel && GOARM=$(GOARM) GOARCH=$(ARCH) CC=$(CC) CGO_ENABLED=1 ./build"
"curl -sSL https://github.com/coreos/flannel/archive/v${TAG}.tar.gz | tar -C /flannel -xz --strip-components=1 \
&& cd /flannel && GOARM=$(GOARM) GOARCH=$(ARCH) CC=$(CC) CGO_ENABLED=1 ./build"

# Replace BASEIMAGE with the real base image
cd $(TEMP_DIR) && sed -i "s|BASEIMAGE|$(BASEIMAGE)|g" Dockerfile
Expand Down
6 changes: 6 additions & 0 deletions cluster/images/flannel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ $ make push ARCH=amd64

$ make push ARCH=arm
# ---> gcr.io/google_containers/flannel-arm:TAG

$ make push ARCH=arm64
# ---> gcr.io/google_containers/flannel-arm64:TAG

$ make push ARCH=ppc64le
# ---> gcr.io/google_containers/flannel-ppc64le:TAG
```

If you don't want to push the images, run `make` or `make build` instead
Expand Down
26 changes: 15 additions & 11 deletions cluster/images/hyperkube/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ FROM BASEIMAGE
CROSS_BUILD_COPY qemu-ARCH-static /usr/bin/

RUN DEBIAN_FRONTEND=noninteractive apt-get update -y \
&& DEBIAN_FRONTEND=noninteractive apt-get -yy -q \
install \
&& DEBIAN_FRONTEND=noninteractive apt-get -yy -q install \
iptables \
ethtool \
ca-certificates \
Expand All @@ -34,21 +33,26 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update -y \

RUN cp /usr/bin/nsenter /nsenter

# Copy the hyperkube binary
COPY hyperkube /hyperkube
RUN chmod a+rx /hyperkube

COPY master-multi.json /etc/kubernetes/manifests-multi/master.json
COPY kube-proxy.json /etc/kubernetes/manifests-multi/kube-proxy.json

# Manifests for the docker guide
COPY master.json /etc/kubernetes/manifests/master.json
COPY etcd.json /etc/kubernetes/manifests/etcd.json
COPY kube-proxy.json /etc/kubernetes/manifests/kube-proxy.json

COPY safe_format_and_mount /usr/share/google/safe_format_and_mount
RUN chmod a+rx /usr/share/google/safe_format_and_mount
# Manifests for the docker-multinode guide
COPY master-multi.json /etc/kubernetes/manifests-multi/master.json
COPY kube-proxy.json /etc/kubernetes/manifests-multi/kube-proxy.json

# Other required scripts for the setup
COPY safe_format_and_mount /usr/share/google/safe_format_and_mount
COPY setup-files.sh /setup-files.sh
RUN chmod a+rx /setup-files.sh

COPY make-ca-cert.sh /make-ca-cert.sh
RUN chmod a+x /make-ca-cert.sh

# Make scripts executable
RUN chmod a+rx \
/hyperkube \
/usr/share/google/safe_format_and_mount \
/setup-files.sh \
/make-ca-cert.sh
Loading

0 comments on commit 4389aa1

Please sign in to comment.