Hi folks! I am trying to override a K8s customizat...
# ask-community
r
Hi folks! I am trying to override a K8s customizations parameter through the prefect cli, see docs. Is this possible/ what would the override flag look like? I can't seem to find anything in the docs. Thanks!
Copy code
prefect deployment build ... --infra-block kubernetes-job/<my-config> --override customizations=[{'op': 'add', 'path': '/spec/template/spec/containers/0/resources', 'value': {'requests': {'cpu': '1000m', 'memory': '1Gi'}}}]
n
hi @Renzo Becerra - are you in the midst of setting up prefect deployments for the first time? im wondering because you're using the old command
prefect deployment build ...
(which makes agent-based deployments instead of
prefect deploy
worker-workpool based deployments) the latter would be recommended going forward as the former is deprecated
r
Hi @Nate, thanks for the quick response! This was set up a while ago and I'm trying to enable resource overrides as well as K8s annotations --
/spec/template/metadata/annotations/
n
everything on the infra block should be available for override from the cli with the
override
flag, so i think you are on the right track what are you running into trouble with?
r
I'm specifying this cli flag to override customizations but am running into an unrecognized command error
--override customizations=[{'op': 'add', 'path': '/spec/template/spec/containers/0/resources', 'value': {'requests': {'cpu': '1000m', 'memory': '1Gi'}}}]
Would you happen to have an example of how I would override customizations?
k
do you have the stack trace with the error you're seeing?
r
@Kevin Grismore
Copy code
... customizations=[{'op': 'add', 'path': '/spec/template/spec/containers/0/resources', 'value': {'requests': {'cpu': '999m', 'memory': '1Gi'}}}]
1752024-05-24 19:17:59,772  ERROR    Usage: prefect deployment build [OPTIONS] ENTRYPOINT
176Try 'prefect deployment build --help' for help.
177╭─ Error ──────────────────────────────────────────────────────────────────────╮
178│ Got unexpected extra arguments (add, path:                                   │
179│ /spec/template/spec/containers/0/resources, value: {requests: {cpu: 999m,    │
180│ memory: 1Gi}}}])                                                             │
181╰──────────────────────────────────────────────────────────────────────────────╯
k
hm maybe it's just a quoting issue then?
r
I've tried a couple different combinations like
... --override customizations='[{...}]'
Would you happen to have an example of a customizations override?
k
let me see if I can put something together. It's been a while since I've used infra block style deployments
r
Awesome!
k
I didn't have any issues making a deployment like so
Copy code
prefect deployment build -p agent -ib kubernetes-job/k8s-job -n k8s-agent-deployment suspend_flow.py:suspended_flow --override customizations="[{'op': 'add', 'path': '/spec/template/spec/containers/0/resources', 'value': {'requests': {'cpu': '1000m', 'memory': '1Gi'}}}]" --apply
I guess that's a string though, so not sure how it'll actually be treated
r
Let me try that real quick
@Kevin Grismore Got it figured out. Had to use jsonpatch and wrap list in single quotes. Thanks for your help!
prefect deployment build ... --override customizations='[{"key": "val"}]'
k
nice!
thanks for figuring it out
🙌 1