In Kubernetes cluster, is kubelet just another pod like kube-proxy, core-dns? I can not find kubelet pods in kube-system namespace?

11/6/2021

When I look/list the pods in kube-system namespace, I can see coredns pods, kube-apiserver pods, kube-proxy pods etc but NOT the kubelet pods.
So just wondering why I am not able to see kubelet. I even tried kubectl.exe get pods -owide --all-namespaces but still NO trace of kubelet.

I just want to look at the runtime args passed to the kubelet for some other reason, but I am not able to find it in the first place. Any suggestion on how to find kubelet in the cluster.

Edit - As @jabbson clarified - kubelet is an agent, a binary/service on your k8s node
Could someone help me find this service/binary/process on windows 10. Basically my installation is docker desktop with inbuilt minikube cluster - more details on my installed version are present on this post. Note: i could not find kubelet in windows services or in the list of running process.

-- samshers
kubelet
kubernetes

3 Answers

11/6/2021

Kubernetes is only set of rules, behaviors and APIs. The specific implementation can implement parts in different way.

-- Leszek Mazur
Source: StackOverflow

11/6/2021

Kubelet is not a pod, instead kubelet is an agent, a binary/service on your k8s node. This binary talks to the apiserver and ensures that the required containers are running on its node and that they are healthy.

Starting with Kubernetes version 1.11, kubelet & kube-proxy can be run as native Windows Services.

-- jabbson
Source: StackOverflow

11/8/2021

Kubelet Service

This is a small service in each node responsible for relaying information to and from control plane service. It interacts with etcd store to read configuration details and write values. This communicates with the master component to receive commands and work. The kubelet process then assumes responsibility for maintaining the state of work and the node server. It manages network rules, port forwarding, etc.

The kubelet and kube-proxy are already configured to run as native Windows Services, offering resiliency by re-starting the services automatically in the event of failure (for example a process crash). You have two options for configuring these node components as services.

You can run the kubelet and kube-proxy as native Windows Services using sc.exe.

 # Create the services for kubelet and kube-proxy in two separate commands
    sc.exe create <component_name> binPath= "<path_to_binary> --service <other_args>"
    
    # Please note that if the arguments contain spaces, they must be escaped.
    sc.exe create kubelet binPath= "C:\kubelet.exe --service --hostname-override 'minion' <other_args>"
    
    # Start the services
    Start-Service kubelet
    Start-Service kube-proxy
    
    # Stop the service
    Stop-Service kubelet (-Force)
    Stop-Service kube-proxy (-Force)
    
    # Query the service status
    Get-Service kubelet
    Get-Service kube-proxy

2.- Using nssm.exe

You can also always use alternative service managers like nssm.exe to run these processes (flanneld, kubelet & kube-proxy) in the background for you. You can use this sample script, leveraging nssm.exe to register kubelet, kube-proxy, and flanneld.exe to run as Windows services in the background.

register-svc.ps1 -NetworkMode <Network mode> -ManagementIP <Windows Node IP> -ClusterCIDR <Cluster subnet> -KubeDnsServiceIP <Kube-dns Service IP> -LogDir <Directory to place logs>

# NetworkMode      = The network mode l2bridge (flannel host-gw, also the default value) or overlay (flannel vxlan) chosen as a network solution
# ManagementIP     = The IP address assigned to the Windows node. You can use ipconfig to find this
# ClusterCIDR      = The cluster subnet range. (Default value 10.244.0.0/16)
# KubeDnsServiceIP = The Kubernetes DNS service IP (Default value 10.96.0.10)
# LogDir           = The directory where kubelet and kube-proxy logs are redirected into their respective output files (Default value C:\k)

If the above referenced script is not suitable, you can manually configure nssm.exe using the following examples.

# Register flanneld.exe
nssm install flanneld C:\flannel\flanneld.exe
nssm set flanneld AppParameters --kubeconfig-file=c:\k\config --iface=<ManagementIP> --ip-masq=1 --kube-subnet-mgr=1
nssm set flanneld AppEnvironmentExtra NODE_NAME=<hostname>
nssm set flanneld AppDirectory C:\flannel
nssm start flanneld

# Register kubelet.exe
# Microsoft releases the pause infrastructure container at mcr.microsoft.com/oss/kubernetes/pause:1.4.1
nssm install kubelet C:\k\kubelet.exe
nssm set kubelet AppParameters --hostname-override=<hostname> --v=6 --pod-infra-container-image=mcr.microsoft.com/oss/kubernetes/pause:1.4.1 --resolv-conf="" --allow-privileged=true --enable-debugging-handlers --cluster-dns=<DNS-service-IP> --cluster-domain=cluster.local --kubeconfig=c:\k\config --hairpin-mode=promiscuous-bridge --image-pull-progress-deadline=20m --cgroups-per-qos=false  --log-dir=<log directory> --logtostderr=false --enforce-node-allocatable="" --network-plugin=cni --cni-bin-dir=c:\k\cni --cni-conf-dir=c:\k\cni\config
nssm set kubelet AppDirectory C:\k
nssm start kubelet

# Register kube-proxy.exe (l2bridge / host-gw)
nssm install kube-proxy C:\k\kube-proxy.exe
nssm set kube-proxy AppDirectory c:\k
nssm set kube-proxy AppParameters --v=4 --proxy-mode=kernelspace --hostname-override=<hostname>--kubeconfig=c:\k\config --enable-dsr=false --log-dir=<log directory> --logtostderr=false
nssm.exe set kube-proxy AppEnvironmentExtra KUBE_NETWORK=cbr0
nssm set kube-proxy DependOnService kubelet
nssm start kube-proxy

# Register kube-proxy.exe (overlay / vxlan)
nssm install kube-proxy C:\k\kube-proxy.exe
nssm set kube-proxy AppDirectory c:\k
nssm set kube-proxy AppParameters --v=4 --proxy-mode=kernelspace --feature-gates="WinOverlay=true" --hostname-override=<hostname> --kubeconfig=c:\k\config --network-name=vxlan0 --source-vip=<source-vip> --enable-dsr=false --log-dir=<log directory> --logtostderr=false
nssm set kube-proxy DependOnService kubelet
nssm start kube-proxy

For initial troubleshooting, you can use the following flags in nssm.exe to redirect stdout and stderr to a output file:

nssm set <Service Name> AppStdout C:\k\mysvc.log
nssm set <Service Name> AppStderr C:\k\mysvc.log
-- Vicente Ayala
Source: StackOverflow