1

I have a docker image running supervisord in a kubernetes pod. I would like the output of processes running via supervisord to appear in the k8s logs. It seems that the simplest way to do that is to have the subprocesses write directly to supervisord's stdout. To that end, I can perform the following horrible hack:

root@714811eb811b:/tmp# cat a.sh
#!/bin/sh

exec > /proc/$(cat /tmp/supervisord.pid)/fd/1
echo This text goes to the k8s log
root@714811eb811b:/tmp# cat config
[supervisord]
nodaemon=true
pidfile=/tmp/supervisord.pid

[program:write]
command=/tmp/a.sh
exitcodes=0
root@714811eb811b:/tmp# supervisord -c config
2017-12-02 00:34:14,245 CRIT Supervisor running as root (no user in config file)
2017-12-02 00:34:14,248 INFO supervisord started with pid 451
2017-12-02 00:34:15,256 INFO spawned: 'write' with pid 454
This text goes to the k8s log
2017-12-02 00:34:15,262 INFO exited: write (exit status 0; not expected)
2017-12-02 00:34:16,270 INFO spawned: 'write' with pid 456
This text goes to the k8s log
2017-12-02 00:34:16,276 INFO exited: write (exit status 0; not expected)
^C2017-12-02 00:34:17,027 WARN received SIGINT indicating exit request

As stated above, this is a horrible hack. Is there an appropriate way to tell supervisord to tie stdout of the children to its own stdout? (ie, tell supervisord to do nothing and just let the children inherit the normal file descriptors)

On an unrelated note, why is the script restarting? Even without the explicit assignment of exitcodes, supervisord ought to expect the exit code of 0.

  • shall supervisord be even used in kubernetes environment, as kubernetes deployment controller will take of restarting containers? – Jay Rajput May 26 '18 at 08:06

0 Answers0