2

In this SO article I understand that I can run a sequence of initContainers before running the containers defined in spec.template.spec.containers.

https://stackoverflow.com/questions/40713573/how-to-run-containers-sequentially-as-a-kubernetes-job

I have two independent containers, each of which requires a sequence of initContainers to run in series prior to the container running.

Is it possible to run both sequences of initContainers at the same time? Something like this:

apiVersion: batch/v1
kind: Job
metadata:
  name: my-test-job
spec:
  backoffLimit: 0
  template:
    spec:
      initContainers:
      - name: init1
        image: busybox
        command: ["echo", "Init 1 Ran!"]
      containers:
      - name: task1
        image: busybox
        imagePullPolicy: Always
        command: ["echo", "Task 1 Ran!"]
      restartPolicy: Never

    spec:
      initContainers:
      - name: init2
        image: busybox
        command: ["echo", "Init 2 Ran!"]
      containers:
      - name: task2
        image: busybox
        imagePullPolicy: Always
        command: ["echo", "Task 2 Ran!"]
      restartPolicy: Never

It's not valid to duplicate spec as I did in that example of what I'm attempting to achieve. But it demonstrates the sequence of events I want. Initially init1 and init2 kick off, and once each finishes, task1 and task2 start following their respective init containers.

1

What you are describing is best achieved by either using two jobs or let task 1 also be an init Container as they run in sequence. Alternatively you could use Argo Workflows. https://github.com/argoproj/argo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.