Open Fabinout opened 6 years ago
I have the same issue. I was trying to patch the hostaliases for a deployment.
I followed the documentation and provided a valid yaml but got the same error "found unexpected end of stream"
The only way to make patching work was to use a json string, like this:
kubectl patch deployment mydeployment --patch "{\"spec\":{\"template\":{\"spec\":{\"hostAliases\":[{\"ip\":\"XX.XX.XX.XX\",\"hostnames\":[\"myhostname\"]}]}}}}"
I had to google and try for hours, getting all kind of parsing errors. Finally this post put me on the right path:
If you get the error The specified patch need to be a valid JSON. when you run the above command, you need to modify the above command depending on your operating system, your shell environment and its interpolation behavior.
I am running kubernetes on windows so I looked at the command prompt part:
If you use Command Prompt, you might need to use the following:
minishift.exe openshift config set --patch "{\"corsAllowedOrigins\": [\".*\"]}"
So in my case to make it work I did: 1) Used double quotes instead of single quotes for the patch string 2) I escaped all the double quotes inside the patch string from " to \"
On hindsight this is quite obvious if you are using cmd but I do not think this is properly documented in the kubectl patch page. Or else, the option to patch using a valid yaml file should work. Hope this helps anybody
when I use basic commnad kubectl patch, I have this parsing error .
It works on Shell though