安装环境:
- Linux (自用ubuntu14.04)
- Docker 1.3+
- go 1.3+
- etcd
安装
从github上下载源码
$ git clone https://github.com/kubernetes/kubernetes.git
$ cd kubernetes
有两种安装方法,二选其一,前者方便快捷,后者因要运行测试等,花费时间较长。
1.Build just linux binaries in the container. Pass options and packages as necessary
$ hack/build-go.sh
2.Build everything, test it, and (optionally) upload the results to a GCS bucket
$ build/release.sh
$ cp _output/dockerized/bin/linux/amd64/kube* /usr/bin
查看安装情况
$ kubectl version
提示
[root@root]# Client Version: version.Info{Major:"1", Minor:"2+", GitVersion:"v1.2.0-alpha.8.693+5b415a7aede533", GitCommit:"5b415a7aede5338595b06e4f4625736b18c185e3", GitTreeState:"clean"}
[root@root]# error: couldn't read version from server: Get http://localhost:8080/api: dial tcp 127.0.0.1:8080: connection refused
安装成功,只是没启动cluster
Starting the cluster
$ cd kubernetes
$ hack/local-up-cluster.sh
之后你在运行kubectl version
[root@root]# Client Version: version.Info{Major:"1", Minor:"2+", GitVersion:"v1.2.0-alpha.8.693+5b415a7aede533", GitCommit:"5b415a7aede5338595b06e4f4625736b18c185e3", GitTreeState:"clean"}
[root@root]# Server Version: version.Info{Major:"1", Minor:"2+", GitVersion:"v1.2.0-alpha.8.693+5b415a7aede533", GitCommit:"5b415a7aede5338595b06e4f4625736b18c185e3", GitTreeState:"clean"}
启动一个容器
$ cluster/kubectl.sh get pods
$ cluster/kubectl.sh get services
$ cluster/kubectl.sh get replicationcontrollers
$ cluster/kubectl.sh run my-nginx --image=nginx --replicas=2 --port=80
## begin wait for provision to complete, you can monitor the docker pull by opening a new terminal
$ sudo docker images
## you should see it pulling the nginx image, once the above command returns it
$ sudo docker ps
## you should see your container running!
$ exit
## end wait