zoukankan      html  css  js  c++  java
  • 单机运行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 binaries
    curl: (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/amd64
    Starting services now!
    Starting etcd
    etcd -addr 127.0.0.1:4001 -data-dir /tmp/tmp.S62jgzua1y --bind-addr 127.0.0.1:4001 --debug > "/dev/null" 2>/dev/null
    Waiting 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.log
    
    To 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    AGE
    127.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 status
    Local doesn't need special preparations for e2e tests
    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"}
    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 1
    2016/10/04 22:14:42 e2e.go:214: Step 'get status' finished in 49.723737ms
    2016/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 version
    Client 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"}version
    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"}
    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 status
    Local doesn't need special preparations for e2e tests
    Client 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.630847ms
    Local doesn't need special preparations for e2e tests
    2016/10/04 23:09:42 e2e.go:212: Running: Ginkgo tests
    Conformance 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 1
    Running Suite: Kubernetes e2e suite
    ===================================
    Random Seed: 1475593782 - Will randomize all specs
    Will run 95 of 324 specs
    
    Oct  4 23:09:42.319: INFO: >>> kubeConfig: /root/.kube/config
    
    Oct  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 ready
    Oct  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 nodes
    SSSSSS
    ------------------------------
    [k8s.io] Pods

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


     
    运行自己的用例如把ReplicasSet复制重命名为ReplicaSetMali保存在rs_mali.go
    export KUBERNETES_PROVIDER="local" 
    export KUBE_MASTER_IP="127.0.0.1:8080"
    export KUBE_MASTER="opama-HP-EliteBook-8560w"

    执行

    go run hack/e2e.go -v -test  --test_args="--host=http://127.0.0.1:8080 --ginkgo.focus=ReplicaSetMali"
    修改后重新编译e2e 
    go install ./test/e2e
    make WHAT=test/e2e/e2e.test 
     会遇到一些错误,如解析版本号失败:
     
    ? Failure [17.150 seconds]
    [k8s.io] ReplicaSetMali
    /home/opama/workspace/k8s/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/test/e2e/framework/framework.go:685
      should serve a basic image on each replica with a public image [mali] [It]
      /home/opama/workspace/k8s/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/test/e2e/rs_mali.go:40
     
      Expected error:
          <*errors.errorString | 0xc8203ed530>: {
              s: "Unable to parse server version "v1.3.1.1+9ec21ad3522752": Invalid character(s) found in patch number "1.1"",
          }
          Unable to parse server version "v1.3.1.1+9ec21ad3522752": Invalid character(s) found in patch number "1.1"
      not to have occurred
     
     如取到的podname含特殊字符:
    Oct  5 12:50:29.746: INFO: Controller my-hostname-basic-f2fde265-8ab6-11e6-85bb-2c768adbb5f8: Replica 2 [my-hostname-basic-f2fde265-8ab6-11e6-85bb-2c768adbb5f8-ekio4] expected response "my-hostname-basic-f2fde265-8ab6-11e6-85bb-2c768adbb5f8-ekio4" but got "my-hostname-basic-f2fde265-8ab6-11e6-85bb-2c768adbb5f8-ekio4
    "
     
    修改了函数的实现
    err = wait.Poll(retryInterval, retryTimeout, framework.PodProxyResponseChecker(f.Client, f.Namespace.Name, label, name, true, pods).CheckAllResponses)
     
     最后运行成功
    P [PENDING]
    [k8s.io] ReplicaSetMali
    /home/opama/workspace/k8s/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/test/e2e/framework/framework.go:685
      should serve a basic image on each replica with a private image
      /home/opama/workspace/k8s/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes/test/e2e/rs_mali.go:47
    ------------------------------
    SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
    Ran 1 of 326 Specs in 17.141 seconds
    SUCCESS! -- 1 Passed | 0 Failed | 1 Pending | 324 Skipped PASS
  • 相关阅读:
    EF-一对一关系
    EF-生成迁移版本
    打包、压缩指令
    gut pull 拉取出错
    nohup的使用方法
    fopen打开文件出错
    实现多线程下载图片到本地③
    实现单线程下载图片到本地②
    服务器重装系统后终端登录不上去
    简单实现图片抓取下载到本地①
  • 原文地址:https://www.cnblogs.com/opama/p/5931515.html
Copyright © 2011-2022 走看看