CKAD field manual

Kubernetes static Pod YAML example

The kubelet reads Pod files from its manifest directory and keeps those containers running. The API server only receives a mirror.

A technician kneels beside a small capsule that still glows after the hangar lights go out. A technician kneels beside a small capsule that still glows after the hangar lights go out.
Kubelet directory
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
staticPodPath: /etc/kubernetes/manifests
/etc/kubernetes/manifests/static-web.yaml
apiVersion: v1
kind: Pod
metadata:
  name: static-web
  namespace: default
spec:
  containers:
    - name: web
      image: nginx:1.27
Install and see the mirror
mkdir -p /etc/kubernetes/manifests
kubectl get nodes
kubectl get pods -o wide
Stop it
kubectl delete pod static-web-node-1
mv /etc/kubernetes/manifests/static-web.yaml /tmp/static-web.yaml

Fields

staticPodPath
Kubelet config field. kubeadm sets /etc/kubernetes/manifests. The old flag is --pod-manifest-path.
metadata.name
The mirror Pod is this name, a hyphen, then the node name. Read the node with kubectl get nodes.
containers
kind: Pod only. A Deployment file in this directory is not a static Pod.
image
Must already be on the node when the node cannot pull. busybox and nginx tags vary by task.
kubectl get
Shows the mirror. -o wide prints the node. The containers can be up before this object exists.
kubectl delete
Deletes the mirror. The kubelet creates it again from the file.
mv
Out of the directory stops the Pod. Back in starts it. The kubelet scans about every 20 seconds.
mkdir
kubeadm already has /etc/kubernetes/manifests. Create the directory only when it is missing.

Watch

  • The mirror Pod name is metadata.name, a hyphen, and the node name. kubectl delete removes that mirror, and the kubelet writes it back. Move the file out of the manifest directory to stop the containers.
  • kubeadm points the kubelet at /etc/kubernetes/manifests. The config field is staticPodPath. The deprecated flag is --pod-manifest-path. A new file is picked up on the next scan, about every 20 seconds. Restart the kubelet when you change the directory, not when you add a file.
  • The kubelet reads every file in that directory whose name does not start with a dot. A copy left beside the manifest becomes a second Pod. Keep backups in /tmp.
  • The containers keep running while the API server is down. The mirror object is the API’s copy, in the namespace written on the Pod.

Official docs Create static Pods Static Pods

Practice these objects on a live cluster →