can you use kubectl patch to add a value dynamically
This is a bash issue, not necessarily a kubectl
issue!
Because the JSON string requires double quotes, you need to wrap the variable inside single quotes. Try this:
kubectl patch deployment production-art-backend -p {"spec":{"template":{"spec":{"initContainers":[{"name":"run-migrations","image":"'${IMAGE_NAME}'"}]}}}}
Please try below command :
kubectl patch deployment production-art-backend --patch="{\"spec\":{\"template\":{\"spec\":{\"initContainers\":[{\"name\":\"run-migrations\",\"image\":\"$IMAGE_NAME\"}]}}}}"
It worked for me.