kube-up.sh无法在Kubernetes v1.9中初始化集群中的Ubuntu master

时间:2018-01-05 21:57:29

标签: ubuntu kubernetes kubeadm

我正在尝试使用以下内容启动Ubuntu Kubernetes v1.9群集:

export KUBE_ROOT=~/kubernetes
export NUM_NODES=1
export NODE_SIZE=n1-standard-8
export NODE_DISK_SIZE=100GB
export KUBE_GCE_INSTANCE_PREFIX=kubernetes-test

export KUBE_OS_DISTRIBUTION=ubuntu
export KUBE_MASTER_OS_DISTRIBUTION=ubuntu
export KUBE_GCE_MASTER_PROJECT=ubuntu-os-cloud
export KUBE_GCE_MASTER_IMAGE=ubuntu-1604-xenial-v20161130
export KUBE_NODE_OS_DISTRIBUTION=ubuntu
export KUBE_GCE_NODE_PROJECT=ubuntu-os-cloud
export KUBE_GCE_NODE_IMAGE=ubuntu-1604-xenial-v20161130

~/kubernetes/cluster/kube-up.sh 

原样,这会导致初始化失败:

Waiting up to 300 seconds for cluster initialization.

  This will continually check to see if the API for kubernetes is reachable.
  This may time out if there was some uncaught error during start up.

........................................................................................
....................................................Cluster failed to initialize within 300 seconds.

在主节点的日志(/ var / log / syslog)中,我可以看到(1)缺少python-yaml导致的错误:

master configure.sh[2013]: Traceback (most recent call last):
master configure.sh[2013]:   File "<string>", line 2, in <module>
master configure.sh[2013]: ImportError: No module named yaml

修复(见下文)会导致出现有关(2)Docker镜像加载失败的错误消息:

master configure.sh[1979]: Try to load docker image file /home/kubernetes/kube-docker-files/kube-apiserver.tar
master configure.sh[1979]: timeout: failed to run command 'docker': No such file or directory
master configure.sh[1979]: message repeated 4 times: [ timeout: failed to run command 'docker': No such file or directory]
master configure.sh[1979]: Fail to load docker image file /home/kubernetes/kube-docker-files/kube-apiserver.tar after 5 retries. Exit!!
master systemd[1]: kube-master-installation.service: Main process exited, code=exited, status=1/FAILURE
master systemd[1]: Failed to start Download and install k8s binaries and configurations.

我已通过在kubernetes / cluster / gce / gci / configure.sh中包含以下内容来修复问题:

function special-ubuntu-setup {
 # Special installation required for ubuntu 16.04?
 apt-get install python-yaml

 # Install docker
 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
 add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
 apt-get update
 apt-cache policy docker-ce
 apt-get install -y docker-ce
}

然后,在&#34;主循环&#34;在configure.sh的底部,在下载kube-env之前调用该函数:

special-ubuntu-setup

这允许我成功设置群集。但是,这个修复似乎非常糟糕。我尝试将其添加到通过元数据传递给GCE实例的启动脚本,但是在configure.sh之后运行,因此不能修复错误。请注意,使用默认操作系统(cos)运行可以正常工作。

我在这里做错了什么?是否有更好的方法来运行Ubuntu集群?

1 个答案:

答案 0 :(得分:0)

使用kubeadm可能会有更好的运气 - 请参阅kubernetes文档中的using kubeadm create cluster