How to generate token or print for adding worker to master in K8s

On Master node run the below command that print the token and use it on the worker to register with master

root@master:~# kubeadm token create –print-join-command
kubeadm join 101.53.148.104:6443 –token svkmlv.q3b6l3mdya8ehqzi –discovery-token-ca-cert-hash sha256:0f6cddfc3534da50a58a78f6f7d6a943284901b794214e18f2f6c336338278c8
root@master:~#

On the Worker Node 1 & Node 2

root@node2:~# kubeadm join 101.53.148.104:6443 –token svkmlv.q3b6l3mdya8ehqzi –discovery-token-ca-cert-hash sha256:0f6cddfc3534da50a58a78f6f7d6a943284901b794214e18f2f6c336338278c8
[preflight] Running pre-flight checks
[WARNING Swap]: swap is enabled; production deployments should disable swap unless testing the NodeSwap feature gate of the kubelet
[preflight] Reading configuration from the cluster…
[preflight] FYI: You can look at this config file with ‘kubectl -n kube-system get cm kubeadm-config -o yaml’
[kubelet-start] Writing kubelet configuration to file “/var/lib/kubelet/config.yaml”
[kubelet-start] Writing kubelet environment file with flags to file “/var/lib/kubelet/kubeadm-flags.env”
[kubelet-start] Starting the kubelet
[kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap…
[kubelet-check] Initial timeout of 40s passed.
[kubelet-check] It seems like the kubelet isn’t running or healthy.
[kubelet-check] The HTTP call equal to ‘curl -sSL http://localhost:10248/healthz’ failed with error: Get “http://localhost:10248/healthz”: dial tcp 127.0.0.1:10248: connect: connection refused.
[kubelet-check] It seems like the kubelet isn’t running or healthy.
[kubelet-check] The HTTP call equal to ‘curl -sSL http://localhost:10248/healthz’ failed with error: Get “http://localhost:10248/healthz”: dial tcp 127.0.0.1:10248: connect: connection refused.
[kubelet-check] It seems like the kubelet isn’t running or healthy.
[kubelet-check] The HTTP call equal to ‘curl -sSL http://localhost:10248/healthz’ failed with error: Get “http://localhost:10248/healthz”: dial tcp 127.0.0.1:10248: connect: connection refused.
[kubelet-check] It seems like the kubelet isn’t running or healthy.
[kubelet-check] The HTTP call equal to ‘curl -sSL http://localhost:10248/healthz’ failed with error: Get “http://localhost:10248/healthz”: dial tcp 127.0.0.1:10248: connect: connection refused.
[kubelet-check] It seems like the kubelet isn’t running or healthy.
[kubelet-check] The HTTP call equal to ‘curl -sSL http://localhost:10248/healthz’ failed with error: Get “http://localhost:10248/healthz”: dial tcp 127.0.0.1:10248: connect: connection refused.

Unfortunately, an error has occurred:
timed out waiting for the condition

This error is likely caused by:
– The kubelet is not running
– The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)

If you are on a systemd-powered system, you can try to troubleshoot the error with the following commands:
– ‘systemctl status kubelet’
– ‘journalctl -xeu kubelet’
error execution phase kubelet-start: timed out waiting for the condition
To see the stack trace of this error execute with –v=5 or higher
root@node2:~# systemctl status kubelet
● kubelet.service – kubelet: The Kubernetes Node Agent
Loaded: loaded (/lib/systemd/system/kubelet.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/kubelet.service.d
└─10-kubeadm.conf
Active: activating (auto-restart) (Result: exit-code) since Tue 2023-04-18 04:39:12 UTC; 7s ago
Docs: https://kubernetes.io/docs/home/
Process: 21945 ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KU>
Main PID: 21945 (code=exited, status=1/FAILURE)

Apr 18 04:39:12 node2.ckalab4.com systemd[1]: kubelet.service: Main process exited, code=exited, status>
Apr 18 04:39:12 node2.ckalab4.com systemd[1]: kubelet.service: Failed with result ‘exit-code’.
lines 1-11/11 (END)
[3]+ Stopped systemctl status kubelet
^C^C
root@node2:~#

kubelet is not running . run below to avoid the above error

  • swapoff -a
  • systemctl restart containerd
  • kubeadm join command ………………………

root@node1:~# kubeadm join 101.53.148.104:6443 –token hnecpi.uoauk5vtewpialas –discovery-token-ca-cert-hash sha256:0f6cddfc3534da50a58a78f6f7d6a943284901b794214e18f2f6c336338278c8
[preflight] Running pre-flight checks
[preflight] Reading configuration from the cluster…
[preflight] FYI: You can look at this config file with ‘kubectl -n kube-system get cm kubeadm-config -o yaml’
[kubelet-start] Writing kubelet configuration to file “/var/lib/kubelet/config.yaml”
[kubelet-start] Writing kubelet environment file with flags to file “/var/lib/kubelet/kubeadm-flags.env”
[kubelet-start] Starting the kubelet
[kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap…

This node has joined the cluster:

  • Certificate signing request was sent to apiserver and a response was received.
  • The Kubelet was informed of the new secure connection details.

Run ‘kubectl get nodes’ on the control-plane to see this node join the cluster.

root@node1:~#

Refer below screen .

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *