I have a Kubernetes cluster (Docker and containerd) where I deployed the Weave CNI plugin.
When inspecting the master node processes (ps -aef --forest) I can see that the containerd-shim process that runs the weave plugin has 3 processes in it's tree:
31175 16241 \_ containerd-shim -namespace moby -workdir /var/lib/containerd/io.containerd.runtime.v1.linux/moby/836489.. -address /run/containerd/contai
31199 31175 | \_ /bin/sh /home/weave/launch.sh
31424 31199 | | \_ /home/weave/weaver --port=6783 --datapath=datapath --name=36:e4:33:8
31656 31175 | \_ /home/weave/kube-utils -run-reclaim-daemon -node-name=ubuntu -peer-name=36:e4
What I fail to understand is how the kube-utils process (pid 31656), which is issued from the launch.sh script process (pid 31199) is a sibling process of it and not a child process?
I have tried to create a similar environment to emulate this scenario, by creating a docker image from the following:
FROM ubuntu:18.04
ADD ./launch.sh /home/temp/
ENTRYPOINT ["/home/temp/launch.sh"]
Where launch.sh in my case is similar in the idea to that of weave:
#!/bin/sh
start() {
sleep 2000&
}
start &
sleep 4000
After deploying this to the cluster I get the following process tree:
114944 16241 \_ containerd-shim -namespace moby -workdir /var/lib/containerd/io.containerd.runtime.v1.linux/moby/d9a6904 -address /run/containerd/contai
114972 114944 \_ /bin/sh /home/temp/launch.sh
115002 114972 \_ sleep 4000
115003 114972 \_ sleep 2000
And you can see that both processes are children of the main container process and not a sibling.
According to the weave scenario above, I would expect that the sleep 2000 process would be a sibling to the launch.sh process and not a child.
Any idea how to explain the weave situation above? how can I reproduce this locally? or in what scenario is a sibling process created to the container process?
Thank you all.
I reproduced the setup you were having and encountered similar situation (one of the
sleepcommand was not a sibling tolaunch.sh). To achieve that you will need following parameters in yourDeploymentorPodYAML:hostPidYou can read more about
hostPidhere:You can read more about
securityContexthere:It's working with
Weaveas it's having parameters mentioned above. You can look them up here:141172180Also this processes are running by:
Example
This is an example to show how you can have a setup where the
sleepcommand will be a sibling tolaunch.sh.The process can differ:
ConfigMapwith a script as an entrypointlaunch.shfile:Using
ConfigMapwith a script as an entrypointYou can use above script to create a
configMapwhich will be used to run a pod:$ kubectl create cm --from-file=launch.shPodYAML definition:Building an image with all the files included
You can also build an image. Please remember that this image is only for example purposes.
Dockerfile:PodYAML definition:After applying the manifest for this resources (either with built image or with a
ConfigMap), you should be able to run (on a node that is running thisPod):$ ps -aef --forestand see the output similar to this (only part):