源码编译kubernetes

1、版本需求

  1. 部署go

    wget https://dl.google.com/go/go1.12.4.linux-amd64.tar.gz

    go版本

    go version go1.12.4 linux/amd64

  1. 部署kubernetes

    wget https://github.com/kubernetes/kubernetes/archive/v1.15.2.tar.gz

    版本:

    1.15.2

2、源码编译

直接编译也可以分成2种,一种是一次编译出来, 一种是每个模块单独编译

全编译

这种方法比较简单, 进入源码目录直接执行make命令即可, 不过对应的k8s版本, 对go语言版本有一些要求, 具体可看k8s网站或者直接编译会提示需要哪个版本go语言.

make GOFLAGS="-tags=nokmem"

+++ [0806 15:09:17] Building go targets for linux/amd64:
    ./vendor/k8s.io/code-generator/cmd/deepcopy-gen
+++ [0806 15:09:25] Building go targets for linux/amd64:
    ./vendor/k8s.io/code-generator/cmd/defaulter-gen
+++ [0806 15:09:31] Building go targets for linux/amd64:
    ./vendor/k8s.io/code-generator/cmd/conversion-gen
+++ [0806 15:09:44] Building go targets for linux/amd64:
    ./vendor/k8s.io/kube-openapi/cmd/openapi-gen
+++ [0806 15:09:53] Building go targets for linux/amd64:
    ./vendor/github.com/jteeuwen/go-bindata/go-bindata
+++ [0806 15:09:54] Building go targets for linux/amd64:
    cmd/kube-proxy
    cmd/kube-apiserver
    cmd/kube-controller-manager
    cmd/cloud-controller-manager
    cmd/kubelet
    cmd/kubeadm
    cmd/hyperkube
    cmd/kube-scheduler
    vendor/k8s.io/apiextensions-apiserver
    cluster/gce/gci/mounter
    cmd/kubectl
    cmd/gendocs
    cmd/genkubedocs
    cmd/genman
    cmd/genyaml
    cmd/genswaggertypedocs
    cmd/linkcheck
    vendor/github.com/onsi/ginkgo/ginkgo
    test/e2e/e2e.test
    cmd/kubemark
    vendor/github.com/onsi/ginkgo/ginkgo
    test/e2e_node/e2e_node.test

3、编译结果

# ll _output/local/bin/linux/amd64/
total 1829580
-rwxr-xr-x 1 root root  43465184 Aug  6 15:11 apiextensions-apiserver
-rwxr-xr-x 1 root root 100450336 Aug  6 15:11 cloud-controller-manager
-rwxr-xr-x 1 root root   6771616 Aug  6 15:09 conversion-gen
-rwxr-xr-x 1 root root   6775616 Aug  6 15:09 deepcopy-gen
-rwxr-xr-x 1 root root   6738784 Aug  6 15:09 defaulter-gen
-rwxr-xr-x 1 root root 182085616 Aug  6 15:11 e2e_node.test
-rwxr-xr-x 1 root root 128503152 Aug  6 15:11 e2e.test
-rwxr-xr-x 1 root root  42255040 Aug  6 15:11 gendocs
-rwxr-xr-x 1 root root 197043560 Aug  6 15:11 genkubedocs
-rwxr-xr-x 1 root root 204458120 Aug  6 15:11 genman
-rwxr-xr-x 1 root root   4061184 Aug  6 15:11 genswaggertypedocs
-rwxr-xr-x 1 root root  42250944 Aug  6 15:11 genyaml
-rwxr-xr-x 1 root root   8810624 Aug  6 15:11 ginkgo
-rwxr-xr-x 1 root root   4709234 Aug  6 15:09 go2make
-rwxr-xr-x 1 root root   2055040 Aug  6 15:09 go-bindata
-rwxr-xr-x 1 root root 200410920 Aug  6 15:11 hyperkube
-rwxr-xr-x 1 root root  40116672 Aug  6 15:11 kubeadm
-rwxr-xr-x 1 root root 164362656 Aug  6 15:11 kube-apiserver
-rwxr-xr-x 1 root root 116257824 Aug  6 15:11 kube-controller-manager
-rwxr-xr-x 1 root root  42919968 Aug  6 15:11 kubectl
-rwxr-xr-x 1 root root 119473352 Aug  6 15:11 kubelet
-rwxr-xr-x 1 root root 115600288 Aug  6 15:11 kubemark
-rwxr-xr-x 1 root root  36921952 Aug  6 15:11 kube-proxy
-rwxr-xr-x 1 root root  38720608 Aug  6 15:11 kube-scheduler
-rwxr-xr-x 1 root root   5479232 Aug  6 15:11 linkcheck
-rwxr-xr-x 1 root root   1648224 Aug  6 15:11 mounter
-rwxr-xr-x 1 root root  11078336 Aug  6 15:09 openapi-gen

没有经过作者同意,禁止转载

你可能感兴趣的:(源码编译kubernetes)