I installed a Kubernetes master using kubeadm sucessfully on a VM (VirtualBox). The problem is that if I stop the machine and restart it the master node seems to be down:
kubectl get nodes
The connection to the server 10.0.x.x:6443 was refused - did you specify the right host or port?
How can I make sure it will always be up after restarting the VM?
UPDATE:
After restarting VM this is what I have to do to make the master node start:
sudo swapoff -a
sudo systemctl restart kubelet.service
Why? How can I fix it so that it starts without having to input that?
1. Install nmap " sudo apt-get install nmap " 2. listen to port 6443 "nc -l 6443" 3. open a another terminal/window and connect to 6443 port "nc -zv 192.168.
The problem is that if I stop the machine and restart it the master node seems to be down
Since it was kubeadm installation that worked properly before restarts, seems like Env var is missing after restart. Try to run this before kubectl get nodes
:
export KUBECONFIG=/etc/kubernetes/admin.conf
If it starts normally, then you need to make sure that KUBECONFIG
environment variable is properly configured upon restart either adding it to .bashrc
or similar...
Why? How can I fix it so that it starts without having to input that?
Ah, swap file is teasing you. By default kubelet will not start if swap is enabled. You have two options:
/etc/fstab
file. Add #
before line creating swap mount point and next time you restart you won't have it.Allow kubelet to run with swap enabled: I know, not recommended by documentation, but if you like to live dangerous, you can add/edit in /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
following line:
Environment="KUBELET_EXTRA_ARGS=--fail-swap-on=false"
and next restart you will be able to run kubelet with swap enabled.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With