I am trying to update some values in my deployment.
# kubectl get deploy activemq-deployment -o yaml
spec:
.
.
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
.
.
I am trying to update the values of maxUnavailable
and maxSurge
on the fly. The command I am using is :
# kubectl patch deploy activemq-deployment -p '{"spec":{"strategy":{"type":"RollingUpdate","rollingUpdate":{"maxUnavailable":"2","maxSurge":"5"}}}}'
But this command yields the ERROR :
The Deployment "activemq-deployment" is invalid:
* spec.strategy.rollingUpdate.maxUnavailable: Invalid value: "1": must match the regex [0-9]+% (e.g. '1%' or '93%')
* spec.strategy.rollingUpdate.maxSurge: Invalid value: "5": must match the regex [0-9]+% (e.g. '1%' or '93%')
Looks like its expecting only perfectages from me. If I do,
# kubectl patch deploy activemq-deployment -p '{"spec":{"strategy":{"type":"RollingUpdate","rollingUpdate":{"maxUnavailable":"100%","maxSurge":"100%"}}}}'
"activemq-deployment" patched
As you can see, this is successful. But when I created the deployment file, I used integers rather than percentages. Any idea why the patch command doesnt let me post integer values ?
I'd bet $1 it's because the API sees you have provided strings for the values, and expects it to be a percentage (since in yaml, if you say maxSurge: 5
that will be an integer, but maxSurge: 5%
will be a string)
Update the command to be
kubectl patch deploy activemq-deployment -p '{
"spec": {
"strategy": {
"type": "RollingUpdate",
"rollingUpdate": {
"maxUnavailable": 2,
"maxSurge": 5
}
}
}
}'
and I suspect it will do what you intended