Commit aa045f78 authored by Lucas Käldström's avatar Lucas Käldström

Use a patched golang version for building linux/arm, fixes kube-apiserver

parent f89d5006
...@@ -18,8 +18,8 @@ FROM gcr.io/google_containers/kube-cross:KUBE_BUILD_IMAGE_CROSS_TAG ...@@ -18,8 +18,8 @@ FROM gcr.io/google_containers/kube-cross:KUBE_BUILD_IMAGE_CROSS_TAG
# Mark this as a kube-build container # Mark this as a kube-build container
RUN touch /kube-build-image RUN touch /kube-build-image
# TO run as non-root we sometimes need to rebuild go stdlib packages. # To run as non-root we sometimes need to rebuild go stdlib packages.
RUN chmod -R a+rwx /usr/local/go/pkg RUN chmod -R a+rwx /usr/local/go/pkg ${K8S_PATCHED_GOROOT}/pkg
# The kubernetes source is expected to be mounted here. This will be the base # The kubernetes source is expected to be mounted here. This will be the base
# of operations. # of operations.
......
...@@ -35,7 +35,7 @@ RUN for platform in ${KUBE_CROSSPLATFORMS}; do GOOS=${platform%/*} GOARCH=${plat ...@@ -35,7 +35,7 @@ RUN for platform in ${KUBE_CROSSPLATFORMS}; do GOOS=${platform%/*} GOARCH=${plat
# Install g++, then download and install protoc for generating protobuf output # Install g++, then download and install protoc for generating protobuf output
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y g++ rsync apt-utils file \ && apt-get install -y g++ rsync apt-utils file patch \
&& apt-get clean && rm -rf /var/lib/apt/lists/* && apt-get clean && rm -rf /var/lib/apt/lists/*
RUN mkdir -p /usr/local/src/protobuf \ RUN mkdir -p /usr/local/src/protobuf \
...@@ -77,3 +77,16 @@ RUN export ETCD_VERSION=v2.2.1; \ ...@@ -77,3 +77,16 @@ RUN export ETCD_VERSION=v2.2.1; \
&& cd /usr/local/src/etcd \ && cd /usr/local/src/etcd \
&& curl -fsSL https://github.com/coreos/etcd/releases/download/${ETCD_VERSION}/etcd-${ETCD_VERSION}-linux-amd64.tar.gz | tar -xz \ && curl -fsSL https://github.com/coreos/etcd/releases/download/${ETCD_VERSION}/etcd-${ETCD_VERSION}-linux-amd64.tar.gz | tar -xz \
&& ln -s ../src/etcd/etcd-${ETCD_VERSION}-linux-amd64/etcd /usr/local/bin/ && ln -s ../src/etcd/etcd-${ETCD_VERSION}-linux-amd64/etcd /usr/local/bin/
# TODO: Remove the patched GOROOT when we have an official golang that has a working arm and ppc64le linker
ENV K8S_PATCHED_GOLANG_VERSION=1.7.1 \
K8S_PATCHED_GOROOT=/usr/local/go_k8s_patched
RUN mkdir -p ${K8S_PATCHED_GOROOT} \
&& curl -sSL https://github.com/golang/go/archive/go${K8S_PATCHED_GOLANG_VERSION}.tar.gz | tar -xz -C ${K8S_PATCHED_GOROOT} --strip-components=1
COPY golang-patches/CL28857-go1.7.1-luxas.patch ${K8S_PATCHED_GOROOT}/
RUN cd ${K8S_PATCHED_GOROOT} \
&& patch -p1 < CL28857-go1.7.1-luxas.patch \
&& cd src \
&& GOROOT_FINAL=${K8S_PATCHED_GOROOT} GOROOT_BOOTSTRAP=/usr/local/go ./make.bash \
&& for platform in linux/arm; do GOOS=${platform%/*} GOARCH=${platform##*/} GOROOT=${K8S_PATCHED_GOROOT} go install std; done
...@@ -100,7 +100,6 @@ else ...@@ -100,7 +100,6 @@ else
linux/amd64 linux/amd64
darwin/amd64 darwin/amd64
windows/amd64 windows/amd64
linux/arm
) )
fi fi
...@@ -226,7 +225,7 @@ kube::golang::current_platform() { ...@@ -226,7 +225,7 @@ kube::golang::current_platform() {
# for that platform. # for that platform.
kube::golang::set_platform_envs() { kube::golang::set_platform_envs() {
[[ -n ${1-} ]] || { [[ -n ${1-} ]] || {
kube::log::error_exit "!!! Internal error. No platform set in kube::golang::set_platform_envs" kube::log::error_exit "!!! Internal error. No platform set in kube::golang::set_platform_envs"
} }
export GOOS=${platform%/*} export GOOS=${platform%/*}
...@@ -240,6 +239,7 @@ kube::golang::set_platform_envs() { ...@@ -240,6 +239,7 @@ kube::golang::set_platform_envs() {
if [[ ${platform} == "linux/arm" ]]; then if [[ ${platform} == "linux/arm" ]]; then
export CGO_ENABLED=1 export CGO_ENABLED=1
export CC=arm-linux-gnueabi-gcc export CC=arm-linux-gnueabi-gcc
export GOROOT=${K8S_PATCHED_GOROOT}
elif [[ ${platform} == "linux/arm64" ]]; then elif [[ ${platform} == "linux/arm64" ]]; then
export CGO_ENABLED=1 export CGO_ENABLED=1
export CC=aarch64-linux-gnu-gcc export CC=aarch64-linux-gnu-gcc
...@@ -253,6 +253,7 @@ kube::golang::set_platform_envs() { ...@@ -253,6 +253,7 @@ kube::golang::set_platform_envs() {
kube::golang::unset_platform_envs() { kube::golang::unset_platform_envs() {
unset GOOS unset GOOS
unset GOARCH unset GOARCH
unset GOROOT
unset CGO_ENABLED unset CGO_ENABLED
unset CC unset CC
} }
...@@ -477,6 +478,11 @@ kube::golang::build_binaries_for_platform() { ...@@ -477,6 +478,11 @@ kube::golang::build_binaries_for_platform() {
kube::golang::fallback_if_stdlib_not_installable; kube::golang::fallback_if_stdlib_not_installable;
fi fi
# TODO: Remove this temporary workaround when we have the official golang linker working
if [[ ${platform} == "linux/arm" ]]; then
gogcflags="${gogcflags} -largemodel"
fi
if [[ -n ${use_go_build:-} ]]; then if [[ -n ${use_go_build:-} ]]; then
kube::log::progress " " kube::log::progress " "
for binary in "${statics[@]:+${statics[@]}}"; do for binary in "${statics[@]:+${statics[@]}}"; do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment