I am attempting to start a Ubuntu Kubernetes v1.9 cluster with the following:
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
As is, this results in failed initialization:
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.
In the log (/var/log/syslog) on the master node, I can see errors resulting from (1) missing 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
Fixing that (see below) results in an error message concerning (2) failed Docker image loading:
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.
I have fixed the problems by including the following in 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
}
Then, in "main loop" at the bottom of configure.sh, call that function before downloading kube-env:
special-ubuntu-setup
This allows me to successfully set up the cluster. However, this fix seems in very bad form. I tried adding the same to a startup-script passed to GCE instances via metadata, but that runs after configure.sh, and thus does not fix the errors. Note that running with the default OS (cos) works just fine.
What am I doing wrong here? Is there a better way to get a Ubuntu cluster running?
You may have better luck using kubeadm
- see using kubeadm create cluster in the kubernetes documentation.