Gururaj Mohan:
Trying to see what is peculiar with Kubectl replace command. I get this error with ‘replace’ but ‘apply’ goes successful with same yaml. Any reason why ?
Alex Novik:
apply is a declarative command, you can apply part of the settings and it will work, replace is an imperative command, it should follow all the settings for your pod to work, same structure as with create command. replace also converts yaml format into json format in between the changes made to configuration, as it stores last applied configuration.
the output you see is a JSON
Alistair Mackay:
Do the following to completely replace the pod
kubectl replace --force -f poddef.yaml
The pod will be deleted, then recreated with the new spec.
Gururaj Mohan:
Thanks both, but it doesn’t answer my question yet. Only change was the image name and I think it is allowed as per the error,
Jesus Arechiga Jimenez:
Seems like you are adding volumes
and volume mounts
, those cannot be added to an existing pod. Pod needs to be deleted then recreated.
Or replaced with --force