Identifying Static Pods in the Cluster
Start by determining the number of static pods across all namespaces. List all pods with this command:kube-apiserver-controlplane (with “controlplane” appended) indicates that it is a static pod. In our cluster output, there are four static pods on the control plane, while other pods do not have a node name at the end.
Another way to verify if a pod is static is to inspect its YAML configuration. For example, check the Kube API Server pod with:
ownerReferences section. A static pod will have an owner entry like this:
kind: Nodename: controlplane
You can use various filters and selectors with
kubectl for a more in-depth analysis. However, these two methods will suffice to identify static pods.Listing Static Pod Components
To review the static pods currently running, execute:- etcd-controlplane
- kube-apiserver-controlplane
- kube-controller-manager-controlplane
- kube-scheduler-controlplane
Determining the Static Pod Manifest Directory
Static pod definitions are read by the kubelet from a specific manifest directory. To locate this directory, inspect the kubelet configuration file, typically found at/var/lib/kubelet/config.yaml. Look for the staticPodPath parameter:
- etcd.yaml
- kube-apiserver.yaml
- kube-controller-manager.yaml
- kube-scheduler.yaml
Examining the Kube API Server Static Pod
To inspect the Docker image used for the Kube API Server, open the manifest file:image: line. You should encounter a line similar to:
Creating a New Static Pod
Next, create a new static pod namedstatic-busybox using the BusyBox image, running the command sleep 1000. Generate a pod manifest with a dry-run to avoid immediate deployment in the cluster:
/etc/kubernetes/manifests). The kubelet will then detect the new manifest and create the pod. Verify its creation by listing pods:
static-busybox-controlplane in the Running state.
Editing the Static Pod Manifest
To update the static pod with a different image version, edit the file located at/etc/kubernetes/manifests/static-busybox.yaml and change the image line to use busybox:1.28.4:
Always monitor your pod status after making changes to ensure that the updates have been applied correctly.
Deleting a Static Pod
Deleting a static pod managed by the kubelet cannot be achieved permanently by merely running a delete command. For example, executing:static-greenbox-node01, follow these steps:
- SSH into node01 (use the internal IP if necessary).
-
Check the manifest directory on node01. Note that the static pod manifest directory might be custom configured. For example, the kubelet configuration on node01 (located at
/var/lib/kubelet/config.yaml) could specify: -
List the manifest files on node01:
You should see a file named
greenbox.yaml. -
Remove the manifest file with:
static-greenbox-node01 pod. Monitor the change by watching the pods:
Deleting the manifest file is the only way to permanently remove a static pod. Simply deleting the pod using
kubectl delete pod will result in its immediate recreation by the kubelet.Summary
In this lesson, you have accomplished the following:- Identified static pods by their naming conventions and owner references.
- Determined the static pod manifest directory from the kubelet configuration.
- Examined the manifest details, including the Docker image tag, for the Kube API Server.
- Created a new static pod using a dry-run to generate the YAML manifest and placed it in the manifests directory.
- Edited the static pod manifest to update the image version and verified the changes.
- Learned how to permanently delete a static pod by removing its manifest file from the node.