Jyoti Jangid:
Hi, I just have started learning K8s and was setting it on ec2 ubuntu using kubeadm https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/.
I initialized kubernetes by kubelet init
my node is up and kubectl cluster-info
returns info about control-plane & DNS but after sometime the error The connection to the server xxxxxx:6443 was refused - did you specify the right host or port?
arises. These events of cluster-up & again the host/port error runs in loop.
solution tried:
• checked status of docker, kubelet service (running)
• swap is already off
• I have allowed the required ports in security-group
Can anyone help?
unnivkn:
Hi @Jyoti Jangid did you get a chance to run this?
To start using your cluster, you need to run the following as a regular user:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
Alistair Mackay:
Which version of Ubuntu are you using? The newer ones default to cgroups v2 which kubernetes doesn’t like. And there’s also a few other networking settings that need checking.
Using phone right now but will post a follow up tomorrow
Alistair Mackay:
And, if you’re trying to install v1.24, it doesn’t work with docker!
Jyoti Jangid:
I was using Ubuntu 22 and I changed it to 20 version. followed this article. I’m still not sure what was the issue happening. https://www.coachdevops.com/2020/06/how-to-setup-kubernetes-cluster-in.html
Alistair Mackay:
Note I am currently working on an ubuntu 22 kubeadm 1.24 setup using a hypervisor rather than cloud. Below is based on what I’ve found so far. When I have it all working, I’ll publish it on github.
So, we have a few things.
Certainly on ububtu 22, and probably on ubuntu 20, cgroups 2 is the default. To set cgroups 1 as the default do (as root)
vi /etc/default/grub
Make the following edit
GRUB_CMDLINE_LINUX_DEFAULT="systemd.unified_cgroup_hierarchy=0"
then run
update-grub
then restart the machine
If tying to install v1.24 kubernetes, instead of
apt-get install <http://docker.io|docker.io> -y
do
apt-get install containerd -y
… and don’t do any other steps related to docker.
Controlling the containerd
service is the same as for docker - simply substitute containerd
for docker
in systemctl
commands.
The docker
command line is replaced with crictl
command in this setup. crictl
has the same command line arguments as docker
Alistair Mackay:
Also to ensure the iptables is properly enabled, do it with config files.
Again as root
Edit /etc/modules
Add the line
br_netfilter
Create file /etc/sysctl.d/10-kubernetes.conf
Add these lines
net.bridge.bridge-nf-call-iptables=1
net.ipv4.ip_forward=1
Reboot
Jyoti Jangid:
Thank you all, was able to setup K8s cluster