I want to deploy a distributed system with one master and N followers. All the followers run the same image but with different arguments. Since they all terminate after a successful run, Jobs
seems to be a good fit.
However, the examples I can find, e.g., this and this, are all limited to homogeneous pods (also with the same args):
apiVersion: batch/v1
kind: Job
metadata:
name: primes
spec:
template:
metadata:
name: primes
spec:
containers:
- name: primes
image: ubuntu
command: ["bash"]
args: ["-c", "current=0; max=70; echo 1; echo 2; for((i=3;i<=max;)); do for((j=i-1;j>=2;)); do if [ `expr $i % $j` -ne 0 ] ; then current=1; else current=0; break; fi; j=`expr $j - 1`; done; if [ $current -eq 1 ] ; then echo $i; fi; i=`expr $i + 1`; done"]
restartPolicy: Never
I'm new to Kubernetes. Is what I need possible with Jobs? Can somebody point me to some examples for heterogeneous pods?
There is support for a single job with multiple types of pods. You would want to make either two different jobs or a single job where the scripting inside the container detects on its own if it should be a leader or follower. If the leader/follower config is part of the command-line arguments, the former is probably easier. Make one job, wait for it to start, get the hostname of the pod, then start the followers job with that hostname in the podspec.