Static Pods

Static pods are not managed by the kube-apiserver, but rather by the kubelet itself. While there is no Deployment, ReplicaSet, etc., the kubelet will work to keep the pod(s) up and running.

You can tell the kubelet where to read its pod definitions from by passing a parameter or specifying the location in the config. For example, --pod-manifest-path=/etc/kubernetes/manifests. In my test cluster, I’ve checked the kubelet service definition.

$ cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
# Note: This dropin only works with kubeadm and kubelet v1.11+
Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf"

We can see that the literal value isn’t specified. It’s been defined in a config file. So now we take a look at that, and find the staticPodPath key.

$ cat /var/lib/kubelet/config.yaml
runtimeRequestTimeout: 2m0s
serializeImagePulls: true
staticPodPath: /etc/kubernetes/manifests
streamingConnectionIdleTimeout: 4h0m0s
syncFrequency: 1m0s

Now I know where the static manifests are stored. Let’s see what’s there on the master node.

drwxr-xr-x 2 root root 4096 Jan 12 01:30 ./
drwxr-xr-x 6 root root 4096 Jan 12 01:29 ../
-rw------- 1 root root 1945 Jan 12 01:29 etcd.yaml
-rw------- 1 root root 3271 Jan 12 01:30 kube-apiserver.yaml
-rw------- 1 root root 3153 Jan 12 01:30 kube-controller-manager.yaml
-rw------- 1 root root  991 Jan 12 01:30 kube-scheduler.yaml

On the worker nodes, nothing is deployed.

$ ll /etc/kubernetes/manifests
total 8
drwxr-xr-x 2 root root 4096 Jun 18  2019 ./
drwxr-xr-x 4 root root 4096 Jun 18  2019 ../

Let’s create a simple static pod on a worker.


apiVersion: v1
kind: Pod
  creationTimestamp: null
    run: bb-static
  name: bb-static
  - args:
    - sleep
    - "4800"
    image: busybox
    name: bb-static
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Never
status: {}

So now we have a new static manifest deployed.

$ ll /etc/kubernetes/manifests
total 12
drwxr-xr-x 2 root root 4096 Jan 12 19:37 ./
drwxr-xr-x 4 root root 4096 Jun 18  2019 ../
-rw-r--r-- 1 root root  280 Jan 12 19:37 bb-static.yaml

Since we don’t have the kube-apiserver, we can’t use kubectl. However, we can use docker ps to verify that our pod started. And we didn’t have to explicitly deploy the file. Likewise, if we delete the file, the pod will automatically be deleted as well.

$ sudo docker ps
CONTAINER ID        IMAGE                             COMMAND                  CREATED             STATUS              PORTS               NAMES
e3ce8c64c7bb        busybox                           "sleep 4800"             4 minutes ago       Up 4 minutes                            k8s_bb-static_bb-static-runlevl42c.mylabserver.com_default_f6ba23256730627f1d9c400e027ca7fe_0

Of course, we can jump back to our master node and see it.

$ k get po --all-namespaces
NAMESPACE       NAME                                                 READY   STATUS             RESTARTS   AGE
default                 1/1     Running            0          10m

Post to Twitter

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.