Trying to update the resources of my deployment using kubectl patch command, but getting the below error.
kubectl patch statefulset test -n test --patch '{"spec": {"template": {"spec": {"containers": [{"resources": [{"limits": [{"cpu": "4000m","memory": "16Gi"}]},{"requests": [{"cpu": "3000m","memory": "13Gi"}]}]}]}}}}'
Error from server: map: map[resources:[map[limits:[map[cpu:4000m memory:16Gi]]] map[requests:[map[cpu:3000m memory:13Gi]]]]] does not contain declared merge key: name
CodePudding user response:
It needs to know which container you want to patch in the statefulset. You indicate this by including the name of the container.
Also, the json structure of your resources field is incorrect. See the example below for a complete working example:
(replace ??? with the name of the container you want patched)
kubectl patch statefulset test -n test --patch '{"spec": {"template": {"spec": {"containers": [{"name": "???", "resources": {"limits": {"cpu": "4000m","memory": "16Gi"},"requests": {"cpu": "3000m","memory": "13Gi"}}}]}}}}'