kubernetes之hyperkube方式安装文档-代码编译(一)

系统

[root@kubernetes-build k8s.io]# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core) 

安装docker git

yum install docker git -y

clone 代码

[root@kubernetes-build k8s.io]# git clone https://github.com/kubernetes/kubernetes.git
正克隆到 'kubernetes'...
remote: Counting objects: 779809, done.
remote: Compressing objects: 100% (155/155), done.
remote: Total 779809 (delta 87), reused 61 (delta 61), pack-reused 779593
接收对象中: 100% (779809/779809), 554.88 MiB | 1.61 MiB/s, done.
处理 delta 中: 100% (533318/533318), done.
Checking out files: 100% (16584/16584), done.

切换分支

[root@kubernetes-build kubernetes]# git checkout v1.10.4 
Note: checking out 'v1.10.4'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD 目前位于 5ca598b... Merge pull request #64631 from msau42/automated-cherry-pick-of-#64351-upstream-release-1.10
[root@kubernetes-build kubernetes]# git checkout v1.10.4 
HEAD 目前位于 5ca598b... Merge pull request #64631 from msau42/automated-cherry-pick-of-#64351-upstream-release-1.10
[root@kubernetes-build kubernetes]# git status
# 头指针分离于 v1.10.4
无文件要提交,干净的工作区

编译

[root@kubernetes-build kubernetes]# ./build/run.sh make 
+++ [0616 11:33:29] Verifying Prerequisites....
+++ [0616 11:33:29] Building Docker image kube-build:build-7dd30f62df-5-v1.9.3-2
...
...
Go version: go version go1.9.3 linux/amd64
+++ [0616 11:39:02] Building the toolchain targets:
    k8s.io/kubernetes/hack/cmd/teststale
    k8s.io/kubernetes/vendor/github.com/jteeuwen/go-bindata/go-bindata
+++ [0616 11:39:02] Generating bindata:
    test/e2e/generated/gobindata_util.go
No changes in generated bindata file: test/e2e/generated/bindata.go
No changes in generated bindata file: pkg/generated/bindata.go
+++ [0616 11:39:03] 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/kube-aggregator
    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
Env for linux/amd64: GOOS=linux GOARCH=amd64 GOROOT=/usr/local/go CGO_ENABLED= CC=

...
...
Env for linux/amd64: GOOS=linux GOARCH=amd64 GOROOT=/usr/local/go CGO_ENABLED= CC=
+++ [0616 12:04:02] Placing binaries
+++ [0616 12:04:34] Syncing out of container
+++ [0616 12:04:34] Stopping any currently running rsyncd container
+++ [0616 12:04:34] Starting rsyncd container
+++ [0616 12:04:35] Running rsync
+++ [0616 12:05:14] Stopping any currently running rsyncd container

编译时生成的镜像以及起的容器

[root@kubernetes-build kubernetes]# docker images 
REPOSITORY                                       TAG                           IMAGE ID            CREATED             SIZE
kube-build                                       build-7dd30f62df-5-v1.9.3-2   2d1a97d8f7fa        4 minutes ago       2.19 GB
gcr.io/google_containers/hyperkube-amd64         1.7.6                         9029eeadb3b1        35 hours ago        697.6 MB
docker.io/debian                                 jessie                        4eb8376dc2a3        6 weeks ago         126.7 MB
k8s.gcr.io/kube-cross                            v1.9.3-2                      32285b178de2        4 months ago        1.743 GB


[root@kubernetes-build kubernetes]# docker ps 
CONTAINER ID        IMAGE                                    COMMAND             CREATED             STATUS              PORTS               NAMES
097a29cd2847        kube-build:build-7dd30f62df-5-v1.9.3-2   "make"              25 minutes ago      Up 25 minutes                           kube-build-7dd30f62df-5-v1.9.3-2

编译完成时生成的二进制文件都在_output文件夹

[root@kubernetes-build kubernetes]# ls -l 
总用量 344
drwxr-xr-x.  4 root root     73 6月  16 11:32 api
drwxr-xr-x. 13 root root   4096 6月  16 11:32 build
lrwxrwxrwx.  1 root root     21 6月  16 11:10 BUILD.bazel -> build/root/BUILD.root
-rw-r--r--.  1 root root 268499 6月  16 11:32 CHANGELOG-1.10.md
-rw-r--r--.  1 root root    994 6月  16 11:32 CHANGELOG.md
drwxr-xr-x. 13 root root   4096 6月  16 11:32 cluster
drwxr-xr-x. 22 root root   4096 6月  16 11:10 cmd
-rw-r--r--.  1 root root    148 6月  16 11:10 code-of-conduct.md
-rw-r--r--.  1 root root    493 6月  16 11:10 CONTRIBUTING.md
drwxr-xr-x.  7 root root    131 6月  16 11:32 docs
drwxr-xr-x. 34 root root   4096 6月  16 11:32 examples
drwxr-xr-x.  2 root root     69 6月  16 11:32 Godeps
drwxr-xr-x. 11 root root   4096 6月  16 11:32 hack
-rw-r--r--.  1 root root   7604 6月  16 11:10 labels.yaml
-rw-r--r--.  1 root root  11358 6月  16 11:10 LICENSE
drwxr-xr-x.  2 root root   4096 6月  16 11:10 logo
lrwxrwxrwx.  1 root root     19 6月  16 11:10 Makefile -> build/root/Makefile
lrwxrwxrwx.  1 root root     35 6月  16 11:10 Makefile.generated_files -> build/root/Makefile.generated_files
drwxr-xr-x.  4 root root     38 6月  16 12:04 _output
-rw-r--r--.  1 root root    279 6月  16 11:32 OWNERS
-rw-r--r--.  1 root root   3650 6月  16 11:32 OWNERS_ALIASES
drwxr-xr-x. 34 root root   4096 6月  16 11:32 pkg
drwxr-xr-x.  3 root root     44 6月  16 11:32 plugin
-rw-r--r--.  1 root root   3329 6月  16 11:10 README.md
drwxr-xr-x.  3 root root     61 6月  16 11:32 staging
-rw-r--r--.  1 root root   1376 6月  16 11:10 SUPPORT.md
drwxr-xr-x. 13 root root    245 6月  16 11:32 test
drwxr-xr-x.  7 root root    129 6月  16 11:32 third_party
drwxr-xr-x.  4 root root     82 6月  16 11:32 translations
drwxr-xr-x. 11 root root    199 6月  16 11:32 vendor
lrwxrwxrwx.  1 root root     20 6月  16 11:10 WORKSPACE -> build/root/WORKSPACE

打镜像hyperkube镜像

[root@kubernetes-build kubernetes]# cd cluster/images/hyperkube/
[root@kubernetes-build hyperkube]# make build VERSION=1.10.4 ARCH=amd64
...
...
Digest: sha256:cc782ed16599000ca4c85d47ec6264753747ae1e77520894dca84b104a7621e2
 ---> 7812d248bfc9
Step 2 : RUN ln -s /hyperkube /apiserver  && ln -s /hyperkube /controller-manager  && ln -s /hyperkube /kubectl  && ln -s /hyperkube /kubelet  && ln -s /hyperkube /proxy  && ln -s /hyperkube /scheduler  && ln -s /hyperkube /aggregator  && ln -s /hyperkube /usr/local/bin/kube-apiserver  && ln -s /hyperkube /usr/local/bin/kube-controller-manager  && ln -s /hyperkube /usr/local/bin/kubectl  && ln -s /hyperkube /usr/local/bin/kubelet  && ln -s /hyperkube /usr/local/bin/kube-proxy  && ln -s /hyperkube /usr/local/bin/kube-scheduler
 ---> Running in 0744f54015d6
 ---> a5cbad5c6b03
Removing intermediate container 0744f54015d6
Step 3 : COPY hyperkube /hyperkube
 ---> 25e37d2cd8ec
Removing intermediate container d4a1aa86b79a
Successfully built 25e37d2cd8ec
rm -rf "/tmp/hyperkubeVQKZAU"

生成的镜像

[root@kubernetes-build hyperkube]# docker images 
REPOSITORY                                       TAG                           IMAGE ID            CREATED              SIZE
staging-k8s.gcr.io/hyperkube-amd64               1.10.4                        25e37d2cd8ec        About a minute ago   664.1 MB
kube-build                                       build-7dd30f62df-5-v1.9.3-2   2d1a97d8f7fa        35 minutes ago       2.19 GB

这个时候可以打tag对应的镜像仓库了
接下来就是搭建镜像仓库了
参考:
hyperkube

你可能感兴趣的:(kubetnetes)