无法使用命令kubeadm init创建集群

时间:2018-04-07 06:09:03

标签: kubernetes

我想在debian 9.3上安装kubenetes,我按照本文档https://kubernetes.io/docs/setup/independent/install-kubeadm/上的说明操作,无法创建超时错误的集群,我使用的命令如下:

export HTTP_PROXY=http://192.168.56.1:1080  # this is my internet proxy
export HTTPS_PROXY=http://192.168.56.1:1080
export NO_PROXY=127.0.0.1,192.168.56.*,10.244.*,10.96.*
kubeadm init --apiserver-advertise-address=192.168.56.101 --pod-network-cidr=10.244.0.0/16 

最后一个命令挂起1小时并且超时失败,我发现几个容器已经通过命令docker ps运行,正在运行的容器包括kube-controller-manager-amd64,etcd-amd64,kube-apiserver-amd64, kube-scheduler-amd64,4 pause-amd64实例。

错误消息如下

duler-debvm01_kube-system(660259102d57385a8043d025ac189c87)": Get https://192.168.56.101:6443/api/v1/namespaces/kube-system/pods/kube-scheduler-debvm01: net/http: TLS handshake timeout
Apr 06 21:44:49 DebVM01 kubelet[10665]: E0406 21:44:49.923017   10665 reflector.go:205] k8s.io/kubernetes/pkg/kubelet/kubelet.go:474: Failed to list *v1.Node: Get https://192.168.56.101:6443/api/v1/nodes?fieldSelector=metadata.name%3Ddebvm01&limit=500&resourceVersion=0: net/http: TLS handshake timeout
Apr 06 21:44:49 DebVM01 kubelet[10665]: E0406 21:44:49.924966   10665 reflector.go:205] k8s.io/kubernetes/pkg/kubelet/kubelet.go:465: Failed to list *v1.Service: Get https://192.168.56.101:6443/api/v1/services?limit=500&resourceVersion=0: net/http: TLS handshake timeout
Apr 06 21:44:49 DebVM01 kubelet[10665]: E0406 21:44:49.925892   10665 reflector.go:205] k8s.io/kubernetes/pkg/kubelet/config/apiserver.go:47: Failed to list *v1.Pod: Get xxx/api/v1/pods?fieldSelector=spec.nodeName%3Ddebvm01&limit=500&resourceVersion=0: net/http: TLS handshake timeout
Apr 06 21:44:50 DebVM01 kubelet[10665]: E0406 21:44:50.029333   10665 eviction_manager.go:238] eviction manager: unexpected err: failed to get node info: node "debvm01" not found
Apr 06 21:44:50 DebVM01 kubelet[10665]: E0406 21:44:50.379543   10665 kubelet_node_status.go:106] Unable to register node "debvm01" with API server: Post xxx: net/http: TLS handshake timeout
Apr 06 21:44:52 DebVM01 kubelet[10665]: E0406 21:44:52.575452   10665 event.go:209] Unable to write event: 'Post xxxx: net/http: TLS handshake timeout' (may retry after sleeping)
Apr 06 21:44:57 DebVM01 kubelet[10665]: I0406 21:44:57.380498   10665 kubelet_node_status.go:273] Setting node annotation to enable volume controller attach/detach
Apr 06 21:44:57 DebVM01 kubelet[10665]: I0406 21:44:57.430059   10665 kubelet_node_status.go:82] Attempting to register node debvm01
Apr 06 21:45:00 DebVM01 kubelet[10665]: E0406 21:45:00.030635   10665 eviction_manager.go:238] eviction manager: unexpected err: failed to get node info: node "debvm01" not found
Apr 06 21:45:01 DebVM01 kubelet[10665]: I0406 21:45:01.484580   10665 kubelet_node_status.go:85] Successfully registered node debvm01

上述错误消息已被处理并消除了许多重复行,如下所示:

Apr 06 22:46:20 DebVM01 kubelet[10665]: E0406 22:46:20.773690   10665 kubelet.go:2104] Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized
Apr 06 22:46:25 DebVM01 kubelet[10665]: W0406 22:46:25.779141   10665 cni.go:171] Unable to update cni config: No networks found in /etc/cni/net.d

Kubernetes v1.9.3

任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

  

kubeadm init --apiserver-advertise-address = 192.168.56.101   --pod-网络CIDR = 10.244.0.0 / 16

来自kubeadm documentation

  

- apiserver-advertise-address ip-address API服务器将广告其正在收听的IP地址。指定' 0.0.0.0'使用   默认网络接口的地址

     

除非另有说明,否则kubeadm使用默认网关的网络   用于宣传主人IP的界面。如果你想使用不同的   网络接口,请指定 - apiserver-advertise-address = ip-address

来自kubernetes api-server documentation

  

- advertise-address ip-address 将apiserver通告给群集成员的IP地址。这个地址必须   可以通过群集的其余部分访问。如果为空,则为--bind-address   将会被使用。如果未指定--bind-address,则主机默认   接口将被使用。

我做了几个实验,确认有必要将ip-address配置(或添加为辅助IP)到其中一个主实例接口。 只需仔细检查该接口是否已启动。

最后一条错误消息

  

网络插件尚未就绪:cni config未初始化

表示缺少或损坏kubernetes网络子系统。尝试使用

安装/重新安装它
kubectl apply -f https://docs.projectcalico.org/v3.0/getting-started/kubernetes/installation/hosted/kubeadm/1.7/calico.yaml  

此部分在"(3/4)安装pod网络"部分中描述。在你提到的document中。

如果您遇到困难,请尝试按照this手册重新安装群集。