Score:0

Crashing cluster after kubeadm init on VPS

lu flag
Bas

Problem

Whenever I create my cluster, and deploy Flannel, it works for maybe ~5 minutes. When I check the cluster info by kubectl cluster-info, it shows the correct information. After a while, it simply shows

The connection to the server <server_ip>:6443 was refused - did you specify the right host or port?

Cluster information:

Kubernetes version: 1.27.2 Installation method: kubeadm init, directly from the documentation page Host OS: Ubuntu 22.04.2 LTS CNI and version: Flannel 0.22.0 CRI and version: containerd 1.6.21

What I've tried

To start off, I followed this [: https://computingforgeeks.com/deploy-kubernetes-cluster-on-ubuntu-with-kubeadm/. I didn't disable the swap, step 3. The CRI part in my containerd config looks like this:

  [plugins."io.containerd.grpc.v1.cri"]
    stream_server_address = "127.0.0.1"
    stream_server_port = "0"
    systemd_cgroup = true

    [plugins."io.containerd.grpc.v1.cri".cni]
      bin_dir = "/opt/cni/bin"
      conf_dir = "/etc/cni/net.d"
      conf_template = ""
      ip_pref = ""
      max_conf_num = 1

When all ready, I initialized my cluster with sudo kubeadm init --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=<server_ip>. This didn't gave any errors.

Questions

  • What causes this? Is my network configuration off?
  • What step am I missing?
  • For checking logs, what's the pod that can cause this? Mostly the kube-proxy one is that gets an error, but see no concrete information other then dial tcp <serverip>:6443: connect: connection refused at the end of every statement.
Score:1
dk flag

This error The connection to the server <server_ip>:6443 was refused - did you specify the right host or port, it seems it cannot locate the API at port 6443, indicating that the API and the Docker container that is running it are the causes of this error. Therefore, this kind of error will be thrown if docker is down or if anything that is preventing access to docker is interrupted.

As explained in this doc by Greek Diary ‘admin’ which explains how to fix error

1.The kubectl should be executed on the Master Node.

2.Current user must have Kubernetes cluster configuration environment variable (Details of how to are listed under section Preparing to Use Kubernetes as a Regular User), e.g.:

   $ env | grep -i kube
KUBECONFIG=/root/.kube/config

3.The docker service must be running:

 $ systemctl status docker

4.The kubelet service must be running:

$ systemctl status kubelet

5.TCP port 6443 should be listed as listening port:

# netstat -pnlt | grep 6443
tcp6 0 0 :::6443 :::* LISTEN 4546/kube-apiserve

If TCP port 6443 is not available, check firewall/iptables rules matching requirements:

$ firewall-cmd --list-all

Also check kubelet logs:

# journalctl -xeu kubelet

6.Try restarting Kubernetes cluster which will also do some basic checks

 $ kubeadm-setup.sh restart

You can also refer to this doc written by David O'Dell for more information about Troubleshoot kubectl connection refused.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.