<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">On Sat, 13 Apr 2019 at 07:29, Cam Hutchison <<a href="mailto:camh@xdna.net">camh@xdna.net</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Tue, 9 Apr 2019 at 13:22, Christian Stewart <<a href="mailto:christian@paral.in" target="_blank">christian@paral.in</a>> wrote:<br>
><br>
> Fwiw, I'm also integrating kubernetes with buildroot at the moment. I don't see where cgo is required in this way.<br>
><br>
> I'd be happy to compare notes if you'd like?<br>
<br>
My local BR2_EXTERNAL kubernetes config is at<br>
<a href="https://github.com/camh-/clusterpi/tree/master/package/kubernetes" rel="noreferrer" target="_blank">https://github.com/camh-/clusterpi/tree/master/package/kubernetes</a>.<br>
Feel free to take anything from there that is useful.<br></blockquote><div><br></div><div>Also, here are my notes I made at the time. Perhaps they might be useful:</div><div><br></div><div>* Success building kubelet from buildroot</div><div>  + I think I've done that before, but I will next try other components using</div><div>    the same pattern</div><div>  + Kubernetes buildroot config directly uses go to build binaries, does not</div><div>    use kube Makefile or build scripts.</div><div>* Success with kube-proxy and kubeadm</div><div>* kube-proxy, kubelet and kubeadm are the node binaries, all successfully built</div><div>  from a single buildroot invocation. All were built with CGO_ENABLED=1.</div><div>  kube-proxy and kubeadm would normally be build with CGO_ENABLED=0 using the</div><div>  kube build scripts (KUBE_STATIC_LIBRARIES)</div><div>* The buildroot golang support does not allow mixed CGO_ENABLED builds of</div><div>  different binaries. The value for CGO_ENABLED seems to be hard-coded at</div><div>  toolchain build time. I should investigate what it would take to build both</div><div>  CGO_ENABLED=0 and CGO_ENABLED=1 together in the toolchain.</div><div>* kube-apiserver build failed. It needs openapi generated files. I had thought</div><div>  that the openapi generation stuff was for docs - not so. I will have to see</div><div>  what needs to be done to hook in the generated files build too. Shouldn't be</div><div>  too hard as the go compiler can build both host and target binaries, so we</div><div>  don't need a second host-targetting go compiler.</div><div>* Extending the KUBERNETES_BUILD_CMDS to run `make generated_files` worked just</div><div>  fine.</div><div>* kube-apiserver is not linking, emitting the error `direct call too far`. If I</div><div>  override the <a href="http://go.mk">go.mk</a> to force CGO_ENABLED=0, it works. The kube build script</div><div>  builds a bunch of components with CGO_ENABLED=0, but the buildroot golang</div><div>  infra does not support setting CGO_ENABLED - it is hard-coded based on</div><div>  whether the toolchain has threads (BR2_TOOLCHAIN_HAS_THREADS). I will need</div><div>  to somehow override that.</div><div>* Everything builds now (including hyperkube) using the right CGO settings for</div><div>  the right targets.</div><div> </div></div></div></div></div>