Kubernetes: How to run a script with different user from root

1/14/2020

I'm facing an issue on executing a cronjob.Below is the snippet of the code.

 containers:
      - name: ssm1db
        image: anuragh/ubuntu:mycronjob5
        imagePullPolicy: Always
       command:
         - "/bin/sh"
         - "-c"
         - "kubectl exec ssm1db-0 -- bash -c 'whoami; /db2/db2inst1/dba/jobs/dbactivate.sh -d wdp'"

For example. I'm able to execute the below code .Here db2inst1 is the user which i need the script to be executed.

/bin/su -c ./full_online_backup.sh - db2inst1

But while executing using kubectl ,getting below error

/bin/su: /bin/su: cannot execute binary file
command terminated with exit code 126
[root@ssm1db-0 /]# 
-- Anuragh Ravindran
kubernetes
kubernetes-jobs

1 Answer

1/14/2020

Related question : How to start crond as non-root user in a Docker Container?

You would encounter permission issues when running crond in a non root user.

-- japzio
Source: StackOverflow