Static Pods are managed by kubelet on specific minion. As they are not associated with any controller, APIServer has no control over it.

One of the use case for static pod might be for storage like gluster on each minion or maybe for os level debugging on OS like atomic host.

For testing it, I referred kelseyhightower’s standalone kubelet guide.

To install kubelet, we can either download kubelet binary and set it up manually or we can get it from kubernetes-node package,

sudo dnf install -y kubernetes-node

Now, we need to add Path to to the directory containing pod manifest files to run, or the path to a single pod manifest file.

Open /etc/kubernetes/kubelet and add --pod-manifest-path=<manifest_path>, In my case, it’s /home/vagrant

so it will look like,

KUBELET_ARGS="--cgroup-driver=systemd --pod-manifest-path=/home/vagrant/"

You can mention --manifest-url=<URL> as well, so kubelet will download that manifest file from URL and will apply the changes.

Also, set --allow-privileged flag to true in /etc/kubernetes/config


Reload the daemon

systemctl daemon-reload

Start the service

sudo systemctl restart kubelet

Enable the service

sudo systemctl enable kubelet

Check whether kubelet is running or not,

sudo systemctl status kubelet

Running a static pod

I am taking example from official documentation,

apiVersion: v1 
kind: Pod 
 name: static-web 
   role: myrole 
 - name: web 
   image: nginx 
  - name: web 
    containerPort: 80 
    protocol: TCP

As soon as, we put this manifests in /home/vagrant, kubelet will automatically detect it and will start the containers.

You can check running containers by docker ps,

$ docker ps
CONTAINER ID        IMAGE                                                                                     COMMAND                  CREATED             STATUS              PORTS               NAMES
bd4e42a51f4c   "nginx -g 'daemon ..."   4 minutes ago       Up 4 minutes                            k8s_web_static-web-
c0c6c1106515                                                  "/pause"                 5 minutes ago       Up 5 minutes                            k8s_POD_static-web-

For more, you can follow kelsey hightower’s tutorial.