CrashLoopbackOff中的Kubernetes仪表板:初始化与Kubernetes apiserve的连接时出错

时间:2018-06-10 15:16:56

标签: docker kubernetes

我使用kubadm在3节点集群(ubuntu 16.04,VirtualBox)上全新安装kubernetes:

  kubeadm version: &version.Info{Major:"1", Minor:"10",      GitVersion:"v1.10.3", GitCommit:"2bba0127d85d5a46ab4b778548be28623b32d0b0", GitTreeState:"clean", BuildDate:"2018-05-21T09:05:37Z",  GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}

我使用标准的yaml定义安装了kubernetes仪表板:

  kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml

但是我看到吊舱一直在崩溃:

 kube-proxy-6bzmx                        1/1       Running            2          1d
 kube-proxy-9jp98                        1/1       Running            2          1d
 kube-proxy-bppbp                        1/1       Running            0          1d
 kube-scheduler-kubemaster               1/1       Running            2          1d 
 kubernetes-dashboard-7d5dcdb6d9-9snln   0/1       CrashLoopBackOff   1          1m

我已经修改了apiserver-url一行:

--apiserver-host=https://127.0.0.1:6443

我可以成功地从api服务器url卷曲响应:

root@kubemaster:~/dashboard# curl -k https://192.168.99.20:6443/version
{
 "major": "1",
"minor": "10",
"gitVersion": "v1.10.3",
"gitCommit": "2bba0127d85d5a46ab4b778548be28623b32d0b0",
 "gitTreeState": "clean",
"buildDate": "2018-05-21T09:05:37Z",
 "goVersion": "go1.9.3",
"compiler": "gc",
"platform": "linux/amd64"
}

 root@kubemaster:~/dashboard# curl -k  https://127.0.0.1:6443/version
 {
 "major": "1",
 "minor": "10",
 "gitVersion": "v1.10.3",
 "gitCommit": "2bba0127d85d5a46ab4b778548be28623b32d0b0",
 "gitTreeState": "clean",
 "buildDate": "2018-05-21T09:05:37Z",
 "goVersion": "go1.9.3",
 "compiler": "gc",
 "platform": "linux/amd64"
}

这甚至可以在通过主服务器上的docker启动的容器中运行:

 root@79e42d97e37d:/# curl -k https://192.168.99.20:6443/version
 {
 "major": "1",
  "minor": "10",
  "gitVersion": "v1.10.3",
  "gitCommit": "2bba0127d85d5a46ab4b778548be28623b32d0b0",
  "gitTreeState": "clean",
  "buildDate": "2018-05-21T09:05:37Z",
  "goVersion": "go1.9.3",
  "compiler": "gc",
  "platform": "linux/amd64" 

与其中一个从节点一样:

 root@kubenode1:~#  curl -k https://192.168.99.20:6443/version
 { 
  "major": "1",
  "minor": "10",
  "gitVersion": "v1.10.3",
  "gitCommit": "2bba0127d85d5a46ab4b778548be28623b32d0b0",
  "gitTreeState": "clean",
 "buildDate": "2018-05-21T09:05:37Z",
 "goVersion": "go1.9.3",
 "compiler": "gc",
 "platform": "linux/amd64"
 }

但是,重新部署仍会导致pod最终出现在CrashloopBackup中,并出现同样的错误:

停止节点以强制在主服务器上部署仪表板只会导致pod永远处于暂挂状态:

Every 2.0s: kubectl get po -n kube-system                                                                                                Tue Jun  5 05:04:56 2018

NAME                                    READY     STATUS    RESTARTS   AGE 
etcd-kubemaster                         1/1       Running   8          1d
kube-apiserver-kubemaster               1/1       Running   9          1d
kube-controller-manager-kubemaster      1/1       Running   8          1d
kube-dns-86f4d74b45-kf8mr               3/3       Running   21         1d
kube-flannel-ds-5cl8l                   1/1       Running   5          1d
kube-flannel-ds-8fgk6                   1/1       Running   1          1d
kube-flannel-ds-hmzdb                   1/1       Running   9          1d
kube-proxy-6bzmx                        1/1       Running   8          1d
kube-proxy-9jp98                        1/1       Running   3          1d
kube-proxy-bppbp                        1/1       Running   1          1d
kube-scheduler-kubemaster               1/1       Running   9          1d
kubernetes-dashboard-7f86dc5d9c-sdtb5   0/1       Pending   0          4m

但是,我从kube-proxy日志中看到,kube-proxy也无法访问API("拨打tcp 192.168.99.20:6443:getsockopt:连接被拒绝"):

E0609 20:49:25.816749       1 reflector.go:205] k8s.io/kubernetes/pkg/client/informers/informers_generated/internalversion/factory.go:86: Failed to list *core.Service: Get https://192.168.99.20:6443/api/v1/services?limit=500&resourceVersion=0: dial tcp 192.168.99.20:6443: getsockopt: connection refused

到目前为止我尝试过的事情:

1)在linux master上禁用ipv6 2)停止所有节点并确保仪表板仅在主站上部署 3)将API网址从http更改为https

这是一个已知问题吗?或者,我如何获得正在运行的仪表板: - )

提前感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

kubernetes仪表板必须在主节点上运行。

事实证明,我必须绝对确保现在将其部署到群集中其他2个节点中的任何一个上,在这种情况下,只需关闭每个节点上的kube服务即可。

更好的解决方案只是添加一个约束,以限制将仪表板部署到主节点。