Run cron as background process in Kubernetes pod running as non root user

1/20/2022

I have an existing kubernetes deployment, it is used for data processing. We run it as non-root user(which is mandated in our group because of security reasons).

Now, we have a new requirement for which we want to run cron job in the background, I understand that we shouldn't be using multiple processes in a single pod but this is something we need to ship fast and we don't have enough time and resources to re-architect things. I installed cron in my docker image and my trouble is around starting this cron process, I can't start it after starting pod because my user doesn't have root permission to start a service. I tried a few ways to add it to start at boot process list like update-rc.d cron defaults but nothing worked so far. Please guide me if there is a way to make it work.

We are using ubuntu-minimal 20 base image.

-- banjara
cron
kubernetes
ubuntu
ubuntu-20.04

1 Answer

1/20/2022

You can run cron specific for a given user. Have you tried adding your user login to: /etc/cron.allow? It is described in this comment: https://stackoverflow.com/a/53524203/12508141

There is a more detailed description of cron.allow mechanism: https://docs.oracle.com/cd/E19253-01/817-0403/sysrescron-23/index.html

-- mik0w
Source: StackOverflow