kubernetes: changing update strategy and "applying" is not allowed
I have a replicaset running without a deployment strategy pre-defined.
When defining one in the template, and setting its type to Recreate, when deploying with kubectl apply, I get:
spec.strategy.rollingUpdate: Forbidden: may not be specified when strategy `type` is 'Recreate'
I would expect the strategy to be allowed to change using apply, and have it apply to the current rollout as well.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 22 (13 by maintainers)
Commits related to this issue
- try to fix cannot apply strategy change to Recreate: relevant issue: kubernetes/kubernetes/issues/24198 — committed to rivernews/terraform-digitalocean-kubernetes-microservice by rivernews 4 years ago
I can confirm this worked for me under Kubernetes 1.6.1 using explicit null.
I did a test like this:
Then apply:
It’s not a bug in apply as much as a shortcoming. apply merges changes by the user with the live state. There’s no way for apply to know that those 2 fields are related. The rollingUpdate field would need to be explicitly nulled.
I’m trying to support the following configuration syntax to generate a patch that includes
nullvalues given by the user.To achieve this we need:
nullvalues to the end patch (3d7ccf4cb8fcab54a84ee77fc0a2e9ac4a7e42ea)nullvalues from the configuration file (WIP: 08da2281c64685bc9c37361f3de33efd4b8d635f)The problem rises by the fact that we:
CreateThreeWayMergePatchaccepts[]byte)Between steps 1 and 2,
nullvalues are not preserved. In other words there is no way to distinct a field that is declared with null and a non existing field. Step 3 also has the problem that there is no way to print a null value.To overcome those issues, I tried to get the configuration file as
[]byte(read it from source) and merge it withinfo.VersionedObject.I’ll create a PR soon to discuss the issue more explicitly but any early feedback is more than welcomed.
(I’ll pick up this issue)
you could not setup
spec.strategy.rollingUpdatewhile you are usingRecreatestrategy.so if you decide to use
Recreate, just try omitting the rollingUpdate part.