首页 > 代码库 > 单机运行k8s以及e2e

单机运行k8s以及e2e

 
1.在本机启动单机版k8s
 
/home/opama/workspace/k8s/src/k8s.io/kubernetes# hack/local-up-cluster.sh
Go version: go version go1.6.2 linux/amd64+++ [1004 21:39:33] Building the toolchain targets:    k8s.io/kubernetes/hack/cmd/teststale+++ [1004 21:39:33] Building go targets for linux/amd64:    cmd/kubectl    cmd/hyperkube+++ [1004 21:41:08] Placing binariescurl: (7) Failed to connect to 127.0.0.1 port 8080: 拒绝连接API SERVER port is free, proceeding...Detected host and ready to start services.  Doing some housekeeping first...Using GO_OUT /home/opama/workspace/k8s/src/k8s.io/kubernetes/_output/local/bin/linux/amd64Starting services now!Starting etcdetcd -addr 127.0.0.1:4001 -data-dir /tmp/tmp.S62jgzua1y --bind-addr 127.0.0.1:4001 --debug > "/dev/null" 2>/dev/nullWaiting for etcd to come up.+++ [1004 21:41:09] On try 1, etcd: :{"action":"set","node":{"key":"/_test","value":"","modifiedIndex":3,"createdIndex":3}}Waiting for apiserver to come up+++ [1004 21:41:11] On try 2, apiserver: : {  "kind": "PodList",  "apiVersion": "v1",  "metadata": {    "selfLink": "/api/v1/pods",    "resourceVersion": "10"  },  "items": []}Local Kubernetes cluster is running. Press Ctrl-C to shut it down.Logs:  /tmp/kube-apiserver.log  /tmp/kube-controller-manager.log  /tmp/kube-proxy.log  /tmp/kube-scheduler.log  /tmp/kubelet.logTo start using your cluster, open up another terminal/tab and run:  export KUBERNETES_PROVIDER=local  cluster/kubectl.sh config set-cluster local --server=http://127.0.0.1:8080 --insecure-skip-tls-verify=true  cluster/kubectl.sh config set-context local --cluster=local  cluster/kubectl.sh config use-context local  cluster/kubectl.sh

 

 
 
2.看一下是否运行成功
/home/opama/workspace/k8s/src/k8s.io/kubernetes/_output/local/bin# mkdir /home/opama/kube-release/home/opama/workspace/k8s/src/k8s.io/kubernetes/_output/local/bin# mv linux /home/opama/kube-release//home/opama/kube-release/linux/amd64# cp -p kubectl /bin//home/opama/kube-release/linux/amd64# kubectl get node
NAME        STATUS    AGE127.0.0.1   Ready     11m

 

 
 
3.本机运行下e2e用例
 
/home/opama/workspace/k8s/src/k8s.io/kubernetes# KUBERNETES_PROVIDER=local go run hack/e2e.go -v -test  --test_args="--host=http://127.0.0.1:8080" --ginkgo.focus="Secrets"

2016/10/04 22:14:42 e2e.go:212: Running: get statusLocal doesnt need special preparations for e2e testsClient Version: version.Info{Major:"1", Minor:"3+", GitVersion:"v1.3.1-dirty", GitCommit:"fe4aa01af2e1ce3d464e11bc465237e38dbcff27", GitTreeState:"dirty", BuildDate:"2016-09-15T15:47:40Z", GoVersion:"go1.6.2", Compiler:"gc", Platform:"linux/amd64"}error: server version (&version.Info{Major:"1", Minor:"3", GitVersion:"v1.3.1.1+9ec21ad3522752", GitCommit:"9ec21ad3522752415c2f82db9f6aa1117dbe583d", GitTreeState:"clean", BuildDate:"2016-10-04T13:39:33Z", GoVersion:"go1.6.2", Compiler:"gc", Platform:"linux/amd64"}) differs from client version (version.Info{Major:"1", Minor:"3+", GitVersion:"v1.3.1-dirty", GitCommit:"fe4aa01af2e1ce3d464e11bc465237e38dbcff27", GitTreeState:"dirty", BuildDate:"2016-09-15T15:47:40Z", GoVersion:"go1.6.2", Compiler:"gc", Platform:"linux/amd64"})!2016/10/04 22:14:42 e2e.go:218: Error running get status: exit status 12016/10/04 22:14:42 e2e.go:214: Step get status finished in 49.723737ms2016/10/04 22:14:42 e2e.go:189: Testing requested, but e2e cluster not up!exit status 1

 

发现是版本不符合,手动指定kubectl,中间还会遇到node数目检查,我直接修改e2e.go中的minNodeCount=1了
 
/home/opama/workspace/k8s/src/k8s.io/kubernetes# export KUBECTL_PATH=/bin/kubectl/home/opama/workspace/k8s/src/k8s.io/kubernetes# cluster/kubectl.sh versionClient Version: version.Info{Major:"1", Minor:"3", GitVersion:"v1.3.1.1+9ec21ad3522752", GitCommit:"9ec21ad3522752415c2f82db9f6aa1117dbe583d", GitTreeState:"clean", BuildDate:"2016-10-04T13:39:33Z", GoVersion:"go1.6.2", Compiler:"gc", Platform:"linux/amd64"}Server Version: version.Info{Major:"1", Minor:"3", GitVersion:"v1.3.1.1+9ec21ad3522752", GitCommit:"9ec21ad3522752415c2f82db9f6aa1117dbe583d", GitTreeState:"clean", BuildDate:"2016-10-04T13:39:33Z", GoVersion:"go1.6.2", Compiler:"gc", Platform:"linux/amd64"}versionClient Version: version.Info{Major:"1", Minor:"3+", GitVersion:"v1.3.1-dirty", GitCommit:"fe4aa01af2e1ce3d464e11bc465237e38dbcff27", GitTreeState:"dirty", BuildDate:"2016-09-15T15:47:40Z", GoVersion:"go1.6.2", Compiler:"gc", Platform:"linux/amd64"}Server Version: version.Info{Major:"1", Minor:"3", GitVersion:"v1.3.1.1+9ec21ad3522752", GitCommit:"9ec21ad3522752415c2f82db9f6aa1117dbe583d", GitTreeState:"clean", BuildDate:"2016-10-04T13:39:33Z", GoVersion:"go1.6.2", Compiler:"gc", Platform:"linux/amd64"}

 

 
 
创建config文件
 
vim /root/.kube/config{  "User": "root",  "Password": ""}

 

 
本机运行Conformance的e2e用例
/home/opama/workspace/k8s/src/k8s.io/kubernetes# KUBERNETES_PROVIDER=local go run hack/e2e.go -v -test  --test_args="--host=http://127.0.0.1:8080 --ginkgo.focus=\[Conformance\] --ginkgo.skip=\[Serial\]"

 


2016/10/04 23:09:41 e2e.go:212: Running: get statusLocal doesnt need special preparations for e2e testsClient Version: version.Info{Major:"1", Minor:"3", GitVersion:"v1.3.1.1+9ec21ad3522752", GitCommit:"9ec21ad3522752415c2f82db9f6aa1117dbe583d", GitTreeState:"clean", BuildDate:"2016-10-04T13:39:33Z", GoVersion:"go1.6.2", Compiler:"gc", Platform:"linux/amd64"}Server Version: version.Info{Major:"1", Minor:"3", GitVersion:"v1.3.1.1+9ec21ad3522752", GitCommit:"9ec21ad3522752415c2f82db9f6aa1117dbe583d", GitTreeState:"clean", BuildDate:"2016-10-04T13:39:33Z", GoVersion:"go1.6.2", Compiler:"gc", Platform:"linux/amd64"}2016/10/04 23:09:42 e2e.go:214: Step get status finished in 49.630847msLocal doesnt need special preparations for e2e tests2016/10/04 23:09:42 e2e.go:212: Running: Ginkgo testsConformance test: not doing test setup.I1004 23:09:42.300288    7565 e2e.go:243] Starting e2e run "93b93584-8a44-11e6-ba64-2c768adbb5f8" on Ginkgo node 1Running Suite: Kubernetes e2e suite===================================Random Seed: 1475593782 - Will randomize all specsWill run 95 of 324 specsOct  4 23:09:42.319: INFO: >>> kubeConfig: /root/.kube/configOct  4 23:09:42.322: INFO: Waiting up to 10m0s for all pods (need at least 0) in namespace kube-system to be running and readyOct  4 23:09:42.327: INFO: Waiting for pods to enter Success, but no pods in "kube-system" match label map[name:e2e-image-puller]Oct  4 23:09:42.328: INFO: 0 / 0 pods in namespace kube-system are running and ready (0 seconds elapsed)Oct  4 23:09:42.328: INFO: expected 0 pod replicas in namespace kube-system, 0 are Running and Ready.Oct  4 23:09:42.329: INFO: Waiting for pods to enter Success, but no pods in "kube-system" match label map[name:e2e-image-puller]Oct  4 23:09:42.329: INFO: Dumping network health container logs from all nodesSSSSSS------------------------------[k8s.io] Pods

 

注意的是,很多默认的gcr.io镜像是下载不下来的,所以会出错,还是需要去改的



单机运行k8s以及e2e