zarf icon indicating copy to clipboard operation
zarf copied to clipboard

Built in wait for data injections to complete before starting pod

Open AustinAbro321 opened this issue 8 months ago • 0 comments

Is your feature request related to a problem? Please describe.

Data injections currently requires users to have the ###ZARF_DATA_INJECTION_MARKER### template in their podspec otherwise it will not inject data. This is because Zarf expects users to track when their injection is done through this marker, however this can be confusing and non-intuitive. Especially if an application has hot reloading and does not need to wait for data.

I propose we remove this requirement and add a key to dataInjections called injectBeforeStartup which defaults to true. This key would automatically create an init container in the targeted pod to wait for the data injection file similar to what is used in the kiwix example.

It would look like this:

  • Given I have the below yaml for my dataInjection with the propose injectBeforeStartup key
    dataInjections:
      - source: zim-data
        target:
          namespace: kiwix
          selector: app=kiwix-serve
          container: data-loader
          path: /data
        compress: true
        injectBeforeStartup: true
  • When I run zarf package deploy myPackage
  • Then an init container is injected into my targeted pod which will wait for the dataInjection file to exist in the pod.

Describe alternatives you've considered

Another option is to give users the ability to target a PVC rather than pods. Zarf could spin up a pod which adds the data directly to the PVC and shuts down when complete. A potential issue with this method is that it would require users to have their PVCs and pods in separate components if they do not want the pod to be spun up before the data is inserted.

AustinAbro321 avatar Jun 20 '24 17:06 AustinAbro321