diff --git a/develop/developing-environment.md b/develop/developing-environment.md index 2ab479629..2c3e79010 100644 --- a/develop/developing-environment.md +++ b/develop/developing-environment.md @@ -1,131 +1,41 @@ -# Kubernetes开发环境 +# 配置Kubernetes开发环境 -## 配置开发环境 +我们将在Mac上使用docker环境编译kuberentes。 -```sh -apt-get install -y gcc make socat git - -# install docker -curl -fsSL https://get.docker.com/ | sh - -# install etcd -curl -L https://github.com/coreos/etcd/releases/download/v3.0.10/etcd-v3.0.10-linux-amd64.tar.gz -o etcd-v3.0.10-linux-amd64.tar.gz && tar xzvf etcd-v3.0.10-linux-amd64.tar.gz && /bin/cp -f etcd-v3.0.10-linux-amd64/{etcd,etcdctl} /usr/bin && rm -rf etcd-v3.0.10-linux-amd64* - -# install golang -curl -sL https://storage.googleapis.com/golang/go1.8.1.linux-amd64.tar.gz | tar -C /usr/local -zxf - -export GOPATH=/gopath -export PATH=$PATH:$GOPATH/bin:/usr/local/bin:/usr/local/go/bin/ - -# Get essential tools for building kubernetes -go get -u github.com/jteeuwen/go-bindata/go-bindata - -# Get kubernetes code -mkdir -p $GOPATH/src/k8s.io -git clone https://github.com/kubernetes/kubernetes $GOPATH/src/k8s.io/kubernetes -cd $GOPATH/src/k8s.io/kubernetes - -# Start a local cluster -export KUBERNETES_PROVIDER=local -# export EXPERIMENTAL_CRI=true -# export ALLOW_SECURITY_CONTEXT=yes -# set dockerd --selinux-enabled -# export NET_PLUGIN=kubenet -hack/local-up-cluster.sh -``` - -打开另外一个终端,配置kubectl: - -```sh -export KUBECONFIG=/var/run/kubernetes/admin.kubeconfig -cluster/kubectl.sh -``` - -## 编译release版 - -```sh -make quick-release -``` - -## 容器集成开发环境 +## 安装依赖 ``` -hyper run -it feisky/kubernetes-dev bash -# /hack/start-hyperd.sh -# /hack/start-docker.sh -# /hack/start-frakti.sh -# /hack/start-kubernetes-frakti.sh -# /hack/setup-kubectl.sh -# cluster/kubectl.sh +brew install gnu-tar ``` -## 单元测试 +Docker环境,至少需要给容器分配4G内存,在低于3G内存的时候可能会编译失败。 -```sh -# unit test a special package -go test -v k8s.io/kubernetes/pkg/kubelet/kuberuntime -``` +## 执行编译 -## e2e测试 +切换目录到kuberentes源码的根目录下执行: -```sh -make WHAT='test/e2e/e2e.test' -make ginkgo +`./build/run.sh make`可以在docker中执行跨平台编译出二进制文件。 -export KUBERNETES_PROVIDER=local -go run hack/e2e.go -v -test --test_args='--ginkgo.focus=Port\sforwarding' -go run hack/e2e.go -v -test --test_args='--ginkgo.focus=Feature:SecurityContext' -``` - -## Node e2e测试 - -```sh -export KUBERNETES_PROVIDER=local -make test-e2e-node FOCUS="InitContainer" TEST_ARGS="--runtime-integration-type=cri" -``` - -## Bot命令 - -- Jenkins verification: `@k8s-bot verify test this` -- GCE E2E: `@k8s-bot cvm gce e2e test this` -- Test all: `@k8s-bot test this please, issue #IGNORE` -- CRI test: `@k8s-bot cri test this.` -- Verity test: `@k8s-bot verify test this` -- **LGTM (only applied if you are one of assignees):**: `/lgtm` -- LGTM cancel: `/lgtm cancel` - -更多命令见[kubernetes test-infra](https://github.com/kubernetes/test-infra/blob/master/prow/commands.md)。 - -## 有用的git命令 - -拉取pull request到本地: - -```sh -git fetch upstream pull/324/head:branch -git fetch upstream pull/365/merge:branch -``` - -或者配置`.git/config`并运行`git fetch`拉取所有的pull requests: +需要用的的docker镜像: ``` - fetch = +refs/pull/*:refs/remotes/origin/pull/* +gcr.io/google_containers/kube-cross:v1.7.5-2 ``` -## 用docker-machine创建虚拟机的方法 +我将该镜像备份到时速云上了,可供大家使用: -```sh -docker-machine create --driver google --google-project xxxx --google-machine-type n1-standard-2 --google-disk-size 30 kubernetes +``` +index.tenxcloud.com/jimmy/kube-cross:v1.7.5-2 ``` -## Minikube启动本地cluster +该镜像基于Ubuntu构建,大小2.15G,编译环境中包含以下软件: -```sh -$ minikube get-k8s-versions -The following Kubernetes versions are available: - - v1.5.1 - - v1.4.3 - ... +- Go1.7.5 +- etcd +- protobuf +- g++ +- 其他golang依赖包 -# http proxy is required in China -$ minikube start --docker-env HTTP_PROXY=http://proxy-ip:port --docker-env HTTPS_PROXY=http://proxy-ip:port --vm-driver=xhyve --kubernetes-version="v1.6.2" -``` +在我自己的电脑上的整个编译过程大概要半个小时。 +编译完成的二进制文件在`/_output/local/go/bin/`目录下。 \ No newline at end of file