**please help** Cronjob exec from one pod to another

401 views
Skip to first unread message

Matthew Cooper

unread,
Aug 24, 2018, 12:39:41 PM8/24/18
to kubernet...@googlegroups.com
Hello all,

I need to get our Gitlab installation finalized. The final task is performing regular backups. According to the Gitlab dos, they recommend using "kubectl exec" to run the backup command in the pod. In order to make this more reliable, my only idea has been to exec from a Kubernetes CronJob. (If anyone can suggest a better idea that I can put into my Helm chart, I am all ears!)

Unfortunately, I am really struggling to get the command invocation correct. A lot of trial and error here. I've attached my current attempt but imagine I could be pretty far off. All help greatly appreciated!!


Blessings,
Matt

gitlab-backup-cronjob.yaml

Matthias Rampke

unread,
Aug 27, 2018, 5:20:40 AM8/27/18
to kubernet...@googlegroups.com
Instead of `exec`ing around, is it possible to run the backup command from another container in the same pod? Possibly by mounting enough volumes into both? Then you could just run the backup "cron" as part of the Gitlab pod, using cron itself, some lightweight alternative, or even just a shell script with a loop.

Looking at your YAML you are doing interesting things with "command" and "args" that I'm not sure work the right way. A form that has worked well for me is to use YAML's multiline strings to pass the script as a single argument to `sh -c`:

command: /bin/sh
args:
- -c
- |
  POD=$(…)
  kubectl exec …

Hope this helps!
/MR



--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.
Visit this group at https://groups.google.com/group/kubernetes-users.
For more options, visit https://groups.google.com/d/optout.




--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.
Visit this group at https://groups.google.com/group/kubernetes-users.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages