<p>I have been trying to get a basic Kubernetes cluster running according to the following tutorial <a href="https://kubernetes.io/docs/setup/independent/install-kubeadm/" rel="nofollow noreferrer">https://kubernetes.io/docs/setup/independent/install-kubeadm/</a></p>

<p>I started with an up-to-date ubuntu 16.04 system and installed docker.</p>

<p><code>wget -qO- https://get.docker.com/ | sed 's/docker-ce/docker-ce=18.06.3~ce~3-0~ubuntu/' | sh</code></p>

<p>After that I installed the kubelet / Kubeadm and kubectl modules</p>

<pre><code>apt-get update &amp;&amp; apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat &lt;&lt;EOF &gt;/etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
apt-get update
apt-get install -y kubelet kubeadm kubectl
apt-mark hold kubelet kubeadm kubectl
</code></pre>

<p>Made sure that swap etc was off <code>sudo swapoff -a</code></p>

<p>Performed the init using <code>sudo kubeadm init</code></p>

<pre><code>[init] Using Kubernetes version: v1.13.3
...
To start using your cluster
...
mkdir ...
You can now join any ...
...
</code></pre>

<p>I make the .kube folder and config</p>

<pre><code>mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
</code></pre>

<p><code>kubectl cluster-info</code> then shows</p>

<pre><code>To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
The connection to the server 10.117.xxx.xxx:6443 was refused - did you specify the right host or port?
</code></pre>

<p>After giving it a few attempt I once received:</p>

<pre><code>sudo kubectl cluster-info
Kubernetes master is running at https://10.117.xxx.xxx:6443
KubeDNS is running at https://10.117.xxx.xxx:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
</code></pre>

<p>But a second later its back to the permission denied</p>

<pre><code>sudo kubectl cluster-info
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
The connection to the server 10.117.xxx.xxx:6443 was refused - did you specify the right host or port?
</code></pre>

<p>I tried with and without sudo... and <code>sudo kubectl get nodes</code> also refused to work.</p>

<pre><code>The connection to the server 10.117.xxx.xxx:6443 was refused - did you specify the right host or port?
</code></pre>

<p>What am I missing that it won't connect?</p>

<p><code>ping 10.117.xxx.xxx</code> works fine and even <code>ssh</code> to this address works and is the same server.</p>

<p><strong>Edit</strong></p>

<p><code>sudo systemctl restart kubelet.service</code> shows that the cluster comes online but for some reason goes offline within minutes.</p>

<pre><code>kubectl cluster-info
Kubernetes master is running at https://10.117.0.47:6443
KubeDNS is running at https://10.117.0.47:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
...
kubectl cluster-info

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
The connection to the server 10.117.0.47:6443 was refused - did you specify the right host or port?
</code></pre>

<p><strong>edit2</strong></p>

<p>After doing a full reset and using the following init...</p>

<pre><code>sudo kubeadm init --pod-network-cidr=10.244.0.0/16 
</code></pre>

<p>Followed by</p>

<pre><code>kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/a70459be0084506e4ec919aa1c114638878db11b/Documentation/kube-flannel.yml
</code></pre>

<p>Allowed me to install the pod network add-on but was only short-lived.</p>

<pre><code>clusterrole.rbac.authorization.k8s.io/flannel created
clusterrolebinding.rbac.authorization.k8s.io/flannel created
serviceaccount/flannel created
configmap/kube-flannel-cfg created
daemonset.extensions/kube-flannel-ds-amd64 created
daemonset.extensions/kube-flannel-ds-arm64 created
daemonset.extensions/kube-flannel-ds-arm created
daemonset.extensions/kube-flannel-ds-ppc64le created
daemonset.extensions/kube-flannel-ds-s390x created
</code></pre>

<pre><code>kubectl cluster-info
Kubernetes master is running at https://10.117.xxx.xxx:6443
KubeDNS is running at https://10.117.xxx.xxx:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

➜  ~ kubectl cluster-info

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
The connection to the server 10.117.xxx.xxx:6443 was refused - did you specify the right host or port?
</code></pre>

<p><strong>edit3</strong></p>

<p>Removing all docker images, containers etc... and then perform a restart using <code>sudo systemctl restart kubelet.service</code> seems to do the trick for a few minutes but then all docker containers are killed and removed without any signal. How can I look into the logging of these containers to perhaps find out why they are killed?</p>

<p><a href="https://pastebin.com/wWSWXM31" rel="nofollow noreferrer">https://pastebin.com/wWSWXM31</a> log file</p>

Jasper
<p>After reboot got the same error. <code>swapoff -a</code> works for me</p>
