Kubeadm init fails. kube-scheduler fails with error retrieving resource lock kube-system/kube-scheduler: context deadline exceeded (Client.Timeout exceeded while awaiting headers)

Cluster information:

Kubernetes version: 1.27.x
Cloud being used: Local on VM
Installation method: Kubeadm
Host OS: Ubuntu 20.04
CNI and version:
CRI and version:

I have installed kubernetes using kubeadm on Ubuntu 20.04.

root@k8master:~# kubectl get pod -A
NAMESPACE     NAME                             READY   STATUS             RESTARTS        AGE
kube-system   etcd-master                      1/1     Running            0               9m17s
kube-system   kube-apiserver-master            1/1     Running            0               10m
kube-system   kube-controller-manager-master   1/1     Running            6 (2m25s ago)   10m
kube-system   kube-scheduler-master            0/1     CrashLoopBackOff   5 (86s ago)     10m
root@k8master:~#

kube-scheduler-master is in CrashLoopBackOff State with below errors from the exited pod.

I0531 16:58:38.771189       1 leaderelection.go:245] attempting to acquire leader lease kube-system/kube-scheduler...
E0531 16:58:44.216121       1 leaderelection.go:327] error retrieving resource lock kube-system/kube-scheduler: Get "https://192.168.205.10:6443/apis/coordination.k8s.io/v1/namespaces/kube-system/leases/kube-scheduler?timeout=5s": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
E0531 16:59:05.396127       1 leaderelection.go:327] error retrieving resource lock kube-system/kube-scheduler: Get "https://192.168.205.10:6443/apis/coordination.k8s.io/v1/namespaces/kube-system/leases/kube-scheduler?timeout=5s": context deadline exceeded
I0531 16:59:17.578854       1 leaderelection.go:255] successfully acquired lease kube-system/kube-scheduler
E0531 16:59:53.082787       1 leaderelection.go:327] error retrieving resource lock kube-system/kube-scheduler: Get "https://192.168.205.10:6443/apis/coordination.k8s.io/v1/namespaces/kube-system/leases/kube-scheduler?timeout=5s": net/http: request canceled (Client.Timeout exceeded while awaiting headers)
E0531 16:59:58.245627       1 leaderelection.go:327] error retrieving resource lock kube-system/kube-scheduler: Get "https://192.168.205.10:6443/apis/coordination.k8s.io/v1/namespaces/kube-system/leases/kube-scheduler?timeout=5s": context deadline exceeded
I0531 16:59:58.265314       1 leaderelection.go:280] failed to renew lease kube-system/kube-scheduler: timed out waiting for the condition
E0531 17:00:03.677222       1 server.go:226] "Leaderelection lost"

the root cause is the API unable to get cluster metadata from ETCD it will happen due to lack of memory. just cross check the how much memory available? if you have low memory try to scale the memory then restart the system wait for few minutes after logging.