How to mount a volume to a KubernetesJob infrastructure block on a Prefect Deployment?

Rajvir Jhawar

10/10/2022, 1:21 PM
Is it possible to add a volumeMount via json patches in prefect 2? I keep running into path error, when i look at the kubernetes job source code the shortcut for env looks like:
"path": "/spec/template/spec/containers/0/env/-"
Which means the path for the volume mount should be:
"path": "/spec/template/spec/containers/0/volumeMounts/-"
When i use that path it doesn't work, any ideas?
👀 1
@Emil Christensen I am still having issues with this. I tried a few combinations and it still doesn't work.
👀 1
@Anna Geller would you have any examples of volumeMount, i didn't see any on discourse

Anna Geller

10/21/2022, 12:56 PM
how would you do that in a KubernetesJob template? those customizations are essentially a patch to modify/add things to a Kubernetes YAML manifest

Christopher Boyd

10/21/2022, 3:09 PM
A volumeMount looks like:
  - image: <|>
    name: test-container
    - mountPath: /test-ebs
      name: test-volume
so I think a patch might look like:
:gratitude-thank-you: 2
p='[{"op": "replace", "path": "/spec/template/spec/containers/0/volumeMounts", "value": [{"mountPath": "/test-ebs", "name": "test-volume"}]}]'

Rajvir Jhawar

10/21/2022, 4:07 PM
@Christopher Boyd thanks for the help there! I had make a minor change for EKS Fargate (used add instead of replace), but other than that it did the trick.
🙌 1