0
0
Kubernetesdevops~5 mins

Node components (kubelet, kube-proxy, container runtime) in Kubernetes - Commands & Configuration

Choose your learning style9 modes available
Introduction
Kubernetes nodes run software that helps manage containers and network traffic. These node components make sure containers run correctly and can talk to each other.
When you want to run containers on a worker machine in a Kubernetes cluster
When you need to manage container lifecycle on each node automatically
When you want to route network traffic inside the cluster to the right containers
When you want to use a container runtime like containerd or Docker to run containers
When you want to check or troubleshoot why containers on a node are not working
Commands
This command lists all nodes in the Kubernetes cluster to check their status and readiness.
Terminal
kubectl get nodes
Expected OutputExpected
NAME STATUS ROLES AGE VERSION worker-node1 Ready <none> 10d v1.26.0
This command checks if the kubelet service is running on the node. Kubelet manages container lifecycle on the node.
Terminal
systemctl status kubelet
Expected OutputExpected
● kubelet.service - kubelet: The Kubernetes Node Agent Loaded: loaded (/usr/lib/systemd/system/kubelet.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2024-06-10 10:00:00 UTC; 5 days ago
This command checks if the kube-proxy service is running. Kube-proxy manages network rules for routing traffic to containers.
Terminal
systemctl status kube-proxy
Expected OutputExpected
● kube-proxy.service - Kubernetes Kube-Proxy Server Loaded: loaded (/usr/lib/systemd/system/kube-proxy.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2024-06-10 10:00:00 UTC; 5 days ago
This command lists running containers using the container runtime interface. It shows containers managed by containerd or Docker.
Terminal
crictl ps
Expected OutputExpected
CONTAINER IMAGE CREATED STATE NAME ATTEMPT 123abc456def nginx:1.23.0 2 hours ago Running my-nginx 0
Key Concept

If you remember nothing else, remember: kubelet runs containers, kube-proxy routes network traffic, and the container runtime actually runs the container processes on each node.

Common Mistakes
Checking only 'kubectl get pods' without verifying node components
Pods may not run properly if node components like kubelet or container runtime are down, which 'kubectl get pods' alone won't show.
Always check node status with 'kubectl get nodes' and verify kubelet and container runtime services on the node.
Assuming container runtime is always Docker
Modern Kubernetes often uses containerd or other runtimes; commands or troubleshooting steps differ.
Use 'crictl' commands which work with any container runtime that supports the Container Runtime Interface.
Summary
Use 'kubectl get nodes' to check if nodes are ready and part of the cluster.
Check kubelet service status to ensure containers are managed properly on the node.
Check kube-proxy service status to confirm network traffic routing is active.
Use 'crictl ps' to list running containers via the container runtime on the node.