Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to compile the source code of Kubernetes

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article is about how the source code of Kubernetes is compiled. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Prepare for

Install golang and docker separately. Setting the following will be a good habit for golang package compilation.

Export GO111MODULE= "on" export GOPROXY= https://goproxy.cn download source code mkdir-p $GOPATH/src/k8s.iocd $GOPATH/src/k8s.iogit clone https://github.com/kubernetes/kubernetes cd $GOPATH/src/k8s.io/kubernetes compilation mode 1 command

KUBE_BUILD_PLATFORMS specifies the target platform, WHAT specifies the compiled components, and compile-time parameters are passed through GOFLAGS and GOGCFLAGS

Compile the kubelet component here.

Cd kubernetesKUBE_BUILD_PLATFORMS=linux/amd64 make all WHAT=cmd/kubelet GOFLAGS=-v GOGCFLAGS= "- N-l"

If WHAT is not specified, all are compiled.

Make all is compiled in the local environment.

Make release and make quick-release are compiled in a container and packaged into a docker image.

Compile this part of the kubelet code, or execute make clean & & make WHAT=cmd/kubelet

Check the compilation results

The compilation process is long, and the compiled file is in kubernetes/_output.

Compile mode 2 command

Enter cmd/kubelet (take kubelet as an example) to execute

Go build-v

Note 1: an error was reported in the execution. The acquisition of bitbucket.org/bertimus9/systemstat package failed. After many attempts, the installation of go get was successful. Continue the above attempt.

Check the compilation results

If there is no error, the executable file kubelet and the corresponding tar image file are generated (if make release is executed)

# ls cmd/kubelet/app BUILD kubelet kubelet.go OWNERS Thank you for reading! This is the end of this article on "how to compile Kubernetes source code". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report