代码编译
系统
[root@k8s-build kubernetes]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
安装git
docker
yum install git docker -y
启动docker
systemctl enable docker
systemctl start docker
获取代码 选择需要编译的代码分支
git clone https://source.enncloud.cn/kubernetes/kubernetes.git
git checkount v1.11.0
编译
[root@k8s-build kubernetes]# ./build/run.sh make
...
...
...
Env for linux/amd64: GOOS=linux GOARCH=amd64 GOROOT=/usr/local/go CGO_ENABLED= CC=
+++ [0822 21:46:32] Placing binaries
+++ [0822 21:46:55] Syncing out of container
+++ [0822 21:46:55] Stopping any currently running rsyncd container
+++ [0822 21:46:55] Starting rsyncd container
+++ [0822 21:46:55] Running rsync
+++ [0822 21:47:24] Stopping any currently running rsyncd container
查看编译结果
kubernetes目录下 会有_output
目录,编译完成会有以下二进制文件生成
[root@k8s-build kubernetes]# ls -l _output/dockerized/bin/linux/amd64/
总用量 2322844
-rwxr-xr-x 1 root root 59296443 8月 22 21:46 apiextensions-apiserver
-rwxr-xr-x 1 root root 138048580 8月 22 21:46 cloud-controller-manager
-rwxr-xr-x 1 root root 7699847 8月 22 21:32 conversion-gen
-rwxr-xr-x 1 root root 7695690 8月 22 21:31 deepcopy-gen
-rwxr-xr-x 1 root root 7669238 8月 22 21:32 defaulter-gen
-rwxr-xr-x 1 root root 209952968 8月 22 21:46 e2e_node.test
-rwxr-xr-x 1 root root 173405128 8月 22 21:46 e2e.test
-rwxr-xr-x 1 root root 54135796 8月 22 21:46 gendocs
-rwxr-xr-x 1 root root 226059192 8月 22 21:46 genkubedocs
-rwxr-xr-x 1 root root 232022984 8月 22 21:46 genman
-rwxr-xr-x 1 root root 5481582 8月 22 21:46 genswaggertypedocs
-rwxr-xr-x 1 root root 54076580 8月 22 21:46 genyaml
-rwxr-xr-x 1 root root 10649393 8月 22 21:46 ginkgo
-rwxr-xr-x 1 root root 2835466 8月 22 21:32 go-bindata
-rwxr-xr-x 1 root root 227307720 8月 22 21:46 hyperkube
-rwxr-xr-x 1 root root 57247030 8月 22 21:46 kubeadm
-rwxr-xr-x 1 root root 57904311 8月 22 21:46 kube-aggregator
-rwxr-xr-x 1 root root 185143695 8月 22 21:46 kube-apiserver
-rwxr-xr-x 1 root root 153794605 8月 22 21:46 kube-controller-manager
-rwxr-xr-x 1 root root 55269709 8月 22 21:46 kubectl
-rwxr-xr-x 1 root root 162720576 8月 22 21:46 kubelet
-rwxr-xr-x 1 root root 160056808 8月 22 21:46 kubemark
-rwxr-xr-x 1 root root 51916255 8月 22 21:46 kube-proxy
-rwxr-xr-x 1 root root 55475486 8月 22 21:46 kube-scheduler
-rwxr-xr-x 1 root root 6706870 8月 22 21:46 linkcheck
-rwxr-xr-x 1 root root 2330265 8月 22 21:46 mounter
-rwxr-xr-x 1 root root 13634378 8月 22 21:32 openapi-gen
制作镜像
进入到目录k8s.io/kubernetes/cluster/images/hyperkube
执行make build VERSION=v1.11.0 ARCH=amd64
[root@k8s-build hyperkube]# make build VERSION=v1.11.0 ARCH=amd64
...
...
---> 1c1081b4f235
Removing intermediate container 9ff6ab88231b
Step 3/3 : COPY hyperkube /hyperkube
---> c48b7b6e54c8
Removing intermediate container 3f1c19abf0a9
Successfully built c48b7b6e54c8
rm -rf "/tmp/hyperkubenErUHI"
编译以及制作镜像完成时会有以下image生成
[root@k8s-build hyperkube]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
staging-k8s.gcr.io/hyperkube-amd64 v1.11.0 //目标镜像 c48b7b6e54c8 3 minutes ago 625 MB
kube-build build-ce426754e1-5-v1.10.2-1 783e53333137 40 minutes ago 2.58 GB
docker.io/multiarch/qemu-user-static register a63daf7be2dc 8 days ago 1.18 MB
k8s.gcr.io/kube-cross v1.10.2-1 //编译需要的镜像 64c9af34b222 3 months ago 2.08 GB
k8s.gcr.io/debian-hyperkube-base-amd64 0.10 //制作目标镜像的基础镜像 7812d248bfc9 5 months ago 398 MB