https://prefect.io logo
#prefect-community
How to mount a volume to a KubernetesJob infrastructure block on a Prefect Deployment?
# prefect-community
r

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
a

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
c

Christopher Boyd

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

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
16 Views