kubernetes: Building takes TOO much memory and fails

If I try to run hack/update-swagger-spec.sh in my vm with less than 2GB of RAM it fails with this error:

+++ [0725 01:58:03] Building apiserver
+++ [0725 01:58:10] Building go targets for linux/amd64:
    cmd/kube-apiserver
go build github.com/GoogleCloudPlatform/kubernetes/pkg/ui/data/swagger: /usr/local/go/pkg/tool/linux_amd64/6g: signal: killed
!!! Error in /home/vagrant/gopath/src/github.com/GoogleCloudPlatform/kubernetes/hack/lib/golang.sh:388
  'CGO_ENABLED=0 go install -installsuffix cgo "${goflags[@]:+${goflags[@]}}" -ldflags "${version_ldflags}" "${statics[@]:+${statics[@]}}"' exited with status 1
Call stack:
  1: /home/vagrant/gopath/src/github.com/GoogleCloudPlatform/kubernetes/hack/lib/golang.sh:388 kube::golang::build_binaries_for_platform(...)
  2: /home/vagrant/gopath/src/github.com/GoogleCloudPlatform/kubernetes/hack/lib/golang.sh:521 kube::golang::build_binaries(...)
  3: /home/vagrant/gopath/src/github.com/GoogleCloudPlatform/kubernetes/hack/build-go.sh:26 main(...)
Exiting with status 1
!!! Error in /home/vagrant/gopath/src/github.com/GoogleCloudPlatform/kubernetes/hack/lib/golang.sh:439
  'kube::golang::build_binaries "$@"' exited with status 1
Call stack:
  1: /home/vagrant/gopath/src/github.com/GoogleCloudPlatform/kubernetes/hack/lib/golang.sh:439 kube::golang::build_binaries(...)
  2: /home/vagrant/gopath/src/github.com/GoogleCloudPlatform/kubernetes/hack/build-go.sh:26 main(...)
Exiting with status 1
!!! Error in hack/update-swagger-spec.sh:40
  '"${KUBE_ROOT}/hack/build-go.sh" cmd/kube-apiserver' exited with status 1
Call stack:
  1: hack/update-swagger-spec.sh:40 main(...)
Exiting with status 1
+++ [0725 01:58:41] Clean up complete

I found that this file pkg/ui/data/swagger/datafile.go for some reason need a lot of memory to be builded. (it is a huge file btw with 48528 lines)

Is there anything we can do for that? I find it very difficult to run a VM in my laptop with more that 2GB which actually means that I can’t work…

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 2
  • Comments: 47 (39 by maintainers)

Most upvoted comments

I tried build/make-clean.sh && build/run.sh make a couple of times with 5-8 GB or memory assigned to Docker for Mac, these are my results:

Memory Build attempts Successful builds Failed builds
5 GB 3 0 3
6 GB 5 2 3
7 GB 5 3 2
8 GB 5 5 0

In other words, it seems that Docker for Mac needs at least 8 GB to be able to somewhat consistently build Kubernetes currently.

make kubelet also works - everything in cmd is promoted to a top-level make rule 😃

On Fri, Dec 7, 2018 at 10:08 AM Lubomir I. Ivanov notifications@github.com wrote:

the (quick-)release build is a memory hog.

if you want to build only certain components you can use make WHAT:

make WHAT=cmd/kubelet make WHAT=cmd/kubectl

this hardly peaks at 1.5GB for me.

also the control plane and other images are already pre-built with each release and available at gcr.io/ - e.g. gcr.io/google-containers/kube-apiserver.

so unless one wants to re-release k8s i don’t see a reason why make *release should be used.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kubernetes/kubernetes/issues/11852#issuecomment-445316486, or mute the thread https://github.com/notifications/unsubscribe-auth/AFVgVIQV1qmELamQiKgxm-JJNGBUcwwOks5u2q6WgaJpZM4FfkvL .

make kubelet also works - everything in cmd is promoted to a top-level make rule 😃

you just saved me about 1000 keystrokes a week

having 16 GB of ram != exposing 16 GB to the docker daemon depending on your setup. if you’re on docker for mac / windows you’ll need to configure it to allow more ram for the VM

4.5G failed for me this morning, so tired of going by small increases, just threw up 8GB and it worked.

macOS High Sierra: 10.13.4 (17E202) Docker Community Edition 18.03.1-ce-mac65 (24312)

During my most recent experiments, I found that Kubernetes now needs 4.5GB+ to build on osx. https://github.com/kubernetes/kubernetes/pull/62219

I’m running into this problem as well, on a virtualbox ubuntu14.04 3GB RAM vm. It seems to be occuring on branch release-1.2. When I switch to release-1.1, the build works fine. Go1.5.3 installed and passing KUBERNETES_CONTRIB=mesos to make command. There is over 2GB free before the build.

However, build does work fine on release-1.2 branch on bare-metal.

Upping the VM RAM to 4GB (3+GB free on build) fixes issue (as noted in conversation above)

@sttts: I was able to get it to compile with taskset 3 make with 4GB, but I have had it run out of memory and fail a few times.

What’s the recommended amount of memory needed to compile? I am still finding it to be a hit and miss with 4GB.