Skip to content

Commit 73405d0

Browse files
acuminoshafeeqesary1992
authored
[GEP 31] Introduce API changes for supporting InPlaceUpdate (#962)
* Introduce APIs for InPlaceUpdate Co-authored-by: Shafeeque E S <shafeeque.e.s@sap.com> Co-authored-by: Ashish Ranjan Yadav <ashish.ranjan.yadav@sap.com> * Adapt API changes Co-authored-by: Shafeeque E S <shafeeque.e.s@sap.com> Co-authored-by: Ashish Ranjan Yadav <ashish.ranjan.yadav@sap.com> * Add validation for InPlaceUpdate strategy Co-authored-by: Shafeeque E S <shafeeque.e.s@sap.com> Co-authored-by: Ashish Ranjan Yadav <ashish.ranjan.yadav@sap.com> * Nits Co-authored-by: Shafeeque E S <shafeeque.e.s@sap.com> Co-authored-by: Ashish Ranjan Yadav <ashish.ranjan.yadav@sap.com> * Introduce labels constants for InPlaceUpdate Co-Authored-By: Shafeeque E S <shafeeque.e.s@sap.com> Co-Authored-By: Ashish Ranjan Yadav <ashish.ranjan.yadav@sap.com> * Address Review * Add test * Address Review * Address Review * Address Review * Address Review --------- Co-authored-by: Shafeeque E S <shafeeque.e.s@sap.com> Co-authored-by: Ashish Ranjan Yadav <ashish.ranjan.yadav@sap.com>
1 parent 195b829 commit 73405d0

21 files changed

+724
-114
lines changed

docs/documents/apis.md

Lines changed: 124 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,60 @@ Kubernetes meta/v1.Time
836836
</tbody>
837837
</table>
838838
<br>
839+
<h3 id="machine.sapcloud.io/v1alpha1.InPlaceUpdateMachineDeployment">
840+
<b>InPlaceUpdateMachineDeployment</b>
841+
</h3>
842+
<p>
843+
(<em>Appears on:</em>
844+
<a href="#machine.sapcloud.io/v1alpha1.MachineDeploymentStrategy">MachineDeploymentStrategy</a>)
845+
</p>
846+
<p>
847+
<p>InPlaceUpdateMachineDeployment specifies the spec to control the desired behavior of inplace update.</p>
848+
</p>
849+
<table>
850+
<thead>
851+
<tr>
852+
<th>Field</th>
853+
<th>Type</th>
854+
<th>Description</th>
855+
</tr>
856+
</thead>
857+
<tbody>
858+
<tr>
859+
<td>
860+
<code>UpdateConfiguration</code>
861+
</td>
862+
<td>
863+
<em>
864+
<a href="#machine.sapcloud.io/v1alpha1.UpdateConfiguration">
865+
UpdateConfiguration
866+
</a>
867+
</em>
868+
</td>
869+
<td>
870+
<p>
871+
(Members of <code>UpdateConfiguration</code> are embedded into this type.)
872+
</p>
873+
</td>
874+
</tr>
875+
<tr>
876+
<td>
877+
<code>orchestrationType</code>
878+
</td>
879+
<td>
880+
<em>
881+
<a href="#machine.sapcloud.io/v1alpha1.OrchestrationType">
882+
OrchestrationType
883+
</a>
884+
</em>
885+
</td>
886+
<td>
887+
<p>OrchestrationType specifies the orchestration type for the inplace update.</p>
888+
</td>
889+
</tr>
890+
</tbody>
891+
</table>
892+
<br>
839893
<h3 id="machine.sapcloud.io/v1alpha1.LastOperation">
840894
<b>LastOperation</b>
841895
</h3>
@@ -1525,6 +1579,23 @@ RollingUpdateMachineDeployment
15251579
to be.</p>
15261580
</td>
15271581
</tr>
1582+
<tr>
1583+
<td>
1584+
<code>inPlaceUpdate</code>
1585+
</td>
1586+
<td>
1587+
<em>
1588+
<a href="#machine.sapcloud.io/v1alpha1.InPlaceUpdateMachineDeployment">
1589+
InPlaceUpdateMachineDeployment
1590+
</a>
1591+
</em>
1592+
</td>
1593+
<td>
1594+
<em>(Optional)</em>
1595+
<p>InPlaceUpdate update config params. Present only if MachineDeploymentStrategyType =
1596+
InPlaceUpdate.</p>
1597+
</td>
1598+
</tr>
15281599
</tbody>
15291600
</table>
15301601
<br>
@@ -2535,6 +2606,17 @@ see: <a href="https://issues.k8s.io/61966">https://issues.k8s.io/61966</a></p>
25352606
</tbody>
25362607
</table>
25372608
<br>
2609+
<h3 id="machine.sapcloud.io/v1alpha1.OrchestrationType">
2610+
<b>OrchestrationType</b>
2611+
(<code>string</code> alias)</p></h3>
2612+
<p>
2613+
(<em>Appears on:</em>
2614+
<a href="#machine.sapcloud.io/v1alpha1.InPlaceUpdateMachineDeployment">InPlaceUpdateMachineDeployment</a>)
2615+
</p>
2616+
<p>
2617+
<p>OrchestrationType specifies the orchestration type for the inplace update.</p>
2618+
</p>
2619+
<br>
25382620
<h3 id="machine.sapcloud.io/v1alpha1.RollbackConfig">
25392621
<b>RollbackConfig</b>
25402622
</h3>
@@ -2592,6 +2674,46 @@ int64
25922674
<tbody>
25932675
<tr>
25942676
<td>
2677+
<code>UpdateConfiguration</code>
2678+
</td>
2679+
<td>
2680+
<em>
2681+
<a href="#machine.sapcloud.io/v1alpha1.UpdateConfiguration">
2682+
UpdateConfiguration
2683+
</a>
2684+
</em>
2685+
</td>
2686+
<td>
2687+
<p>
2688+
(Members of <code>UpdateConfiguration</code> are embedded into this type.)
2689+
</p>
2690+
</td>
2691+
</tr>
2692+
</tbody>
2693+
</table>
2694+
<br>
2695+
<h3 id="machine.sapcloud.io/v1alpha1.UpdateConfiguration">
2696+
<b>UpdateConfiguration</b>
2697+
</h3>
2698+
<p>
2699+
(<em>Appears on:</em>
2700+
<a href="#machine.sapcloud.io/v1alpha1.InPlaceUpdateMachineDeployment">InPlaceUpdateMachineDeployment</a>,
2701+
<a href="#machine.sapcloud.io/v1alpha1.RollingUpdateMachineDeployment">RollingUpdateMachineDeployment</a>)
2702+
</p>
2703+
<p>
2704+
<p>UpdateConfiguration specifies the udpate configuration for the deployment strategy.</p>
2705+
</p>
2706+
<table>
2707+
<thead>
2708+
<tr>
2709+
<th>Field</th>
2710+
<th>Type</th>
2711+
<th>Description</th>
2712+
</tr>
2713+
</thead>
2714+
<tbody>
2715+
<tr>
2716+
<td>
25952717
<code>maxUnavailable</code>
25962718
</td>
25972719
<td>
@@ -2608,7 +2730,7 @@ Value can be an absolute number (ex: 5) or a percentage of desired machines (ex:
26082730
Absolute number is calculated from percentage by rounding down.
26092731
This can not be 0 if MaxSurge is 0.
26102732
Example: when this is set to 30%, the old machine set can be scaled down to 70% of desired machines
2611-
immediately when the rolling update starts. Once new machines are ready, old machine set
2733+
immediately when the update starts. Once new machines are ready, old machine set
26122734
can be scaled down further, followed by scaling up the new machine set, ensuring
26132735
that the total number of machines available at all times during the update is at
26142736
least 70% of desired machines.</p>
@@ -2633,7 +2755,7 @@ Value can be an absolute number (ex: 5) or a percentage of desired machines (ex:
26332755
This can not be 0 if MaxUnavailable is 0.
26342756
Absolute number is calculated from percentage by rounding up.
26352757
Example: when this is set to 30%, the new machine set can be scaled up immediately when
2636-
the rolling update starts, such that the total number of old and new machines does not exceed
2758+
the update starts, such that the total number of old and new machines does not exceed
26372759
130% of desired machines. Once old machines have been killed,
26382760
new machine set can be scaled up further, ensuring that total number of machines running
26392761
at any time during the update is utmost 130% of desired machines.</p>

kubernetes/crds/machine.sapcloud.io_machinedeployments.yaml

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,47 @@ spec:
164164
description: The MachineDeployment strategy to use to replace existing
165165
machines with new ones.
166166
properties:
167+
inPlaceUpdate:
168+
description: |-
169+
InPlaceUpdate update config params. Present only if MachineDeploymentStrategyType =
170+
InPlaceUpdate.
171+
properties:
172+
maxSurge:
173+
anyOf:
174+
- type: integer
175+
- type: string
176+
description: |-
177+
The maximum number of machines that can be scheduled above the desired number of
178+
machines.
179+
Value can be an absolute number (ex: 5) or a percentage of desired machines (ex: 10%).
180+
This can not be 0 if MaxUnavailable is 0.
181+
Absolute number is calculated from percentage by rounding up.
182+
Example: when this is set to 30%, the new machine set can be scaled up immediately when
183+
the update starts, such that the total number of old and new machines does not exceed
184+
130% of desired machines. Once old machines have been killed,
185+
new machine set can be scaled up further, ensuring that total number of machines running
186+
at any time during the update is utmost 130% of desired machines.
187+
x-kubernetes-int-or-string: true
188+
maxUnavailable:
189+
anyOf:
190+
- type: integer
191+
- type: string
192+
description: |-
193+
The maximum number of machines that can be unavailable during the update.
194+
Value can be an absolute number (ex: 5) or a percentage of desired machines (ex: 10%).
195+
Absolute number is calculated from percentage by rounding down.
196+
This can not be 0 if MaxSurge is 0.
197+
Example: when this is set to 30%, the old machine set can be scaled down to 70% of desired machines
198+
immediately when the update starts. Once new machines are ready, old machine set
199+
can be scaled down further, followed by scaling up the new machine set, ensuring
200+
that the total number of machines available at all times during the update is at
201+
least 70% of desired machines.
202+
x-kubernetes-int-or-string: true
203+
orchestrationType:
204+
description: OrchestrationType specifies the orchestration
205+
type for the inplace update.
206+
type: string
207+
type: object
167208
rollingUpdate:
168209
description: |-
169210
Rolling update config params. Present only if MachineDeploymentStrategyType =
@@ -180,7 +221,7 @@ spec:
180221
This can not be 0 if MaxUnavailable is 0.
181222
Absolute number is calculated from percentage by rounding up.
182223
Example: when this is set to 30%, the new machine set can be scaled up immediately when
183-
the rolling update starts, such that the total number of old and new machines does not exceed
224+
the update starts, such that the total number of old and new machines does not exceed
184225
130% of desired machines. Once old machines have been killed,
185226
new machine set can be scaled up further, ensuring that total number of machines running
186227
at any time during the update is utmost 130% of desired machines.
@@ -195,7 +236,7 @@ spec:
195236
Absolute number is calculated from percentage by rounding down.
196237
This can not be 0 if MaxSurge is 0.
197238
Example: when this is set to 30%, the old machine set can be scaled down to 70% of desired machines
198-
immediately when the rolling update starts. Once new machines are ready, old machine set
239+
immediately when the update starts. Once new machines are ready, old machine set
199240
can be scaled down further, followed by scaling up the new machine set, ensuring
200241
that the total number of machines available at all times during the update is at
201242
least 70% of desired machines.

pkg/apis/machine/types.go

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,10 @@ type MachineDeploymentStrategy struct {
481481
// TODO: Update this to follow our convention for oneOf, whatever we decide it
482482
// to be.
483483
RollingUpdate *RollingUpdateMachineDeployment
484+
485+
// InPlaceUpdate update config params. Present only if MachineDeploymentStrategyType =
486+
// InPlaceUpdate.
487+
InPlaceUpdate *InPlaceUpdateMachineDeployment
484488
}
485489

486490
// MachineDeploymentStrategyType is the strategy to be used for rolling a MachineDeployment
@@ -492,17 +496,34 @@ const (
492496

493497
// RollingUpdateMachineDeploymentStrategyType means that old MCs will be replaced by new one using rolling update i.e gradually scale down the old MCs and scale up the new one.
494498
RollingUpdateMachineDeploymentStrategyType MachineDeploymentStrategyType = "RollingUpdate"
499+
500+
// InPlaceUpdateMachineDeploymentStrategyType signifies that VMs will be updated in place and
501+
// machine objects will gradually transition from the old MachineSet to the new MachineSet without requiring VM recreation.
502+
InPlaceUpdateMachineDeploymentStrategyType MachineDeploymentStrategyType = "InPlaceUpdate"
495503
)
496504

497505
// RollingUpdateMachineDeployment specifies the spec to control the desired behavior of rolling update.
498506
type RollingUpdateMachineDeployment struct {
507+
UpdateConfiguration
508+
}
509+
510+
// InPlaceUpdateMachineDeployment specifies the spec to control the desired behavior of inplace update.
511+
type InPlaceUpdateMachineDeployment struct {
512+
UpdateConfiguration
513+
514+
// OrchestrationType specifies the orchestration type for the inplace update.
515+
OrchestrationType OrchestrationType
516+
}
517+
518+
// UpdateConfiguration specifies the udpate configuration for the deployment strategy.
519+
type UpdateConfiguration struct {
499520
// The maximum number of machines that can be unavailable during the update.
500521
// Value can be an absolute number (ex: 5) or a percentage of desired machines (ex: 10%).
501522
// Absolute number is calculated from percentage by rounding down.
502523
// This can not be 0 if MaxSurge is 0.
503524
// By default, a fixed value of 1 is used.
504525
// Example: when this is set to 30%, the old MC can be scaled down to 70% of desired machines
505-
// immediately when the rolling update starts. Once new machines are ready, old MC
526+
// immediately when the update starts. Once new machines are ready, old MC
506527
// can be scaled down further, followed by scaling up the new MC, ensuring
507528
// that the total number of machines available at all times during the update is at
508529
// least 70% of desired machines.
@@ -515,13 +536,23 @@ type RollingUpdateMachineDeployment struct {
515536
// Absolute number is calculated from percentage by rounding up.
516537
// By default, a value of 1 is used.
517538
// Example: when this is set to 30%, the new MC can be scaled up immediately when
518-
// the rolling update starts, such that the total number of old and new machines do not exceed
539+
// the update starts, such that the total number of old and new machines do not exceed
519540
// 130% of desired machines. Once old machines have been killed,
520541
// new MC can be scaled up further, ensuring that total number of machines running
521542
// at any time during the update is atmost 130% of desired machines.
522543
MaxSurge *intstr.IntOrString
523544
}
524545

546+
// OrchestrationType specifies the orchestration type for the inplace update.
547+
type OrchestrationType string
548+
549+
const (
550+
// OrchestrationTypeAuto signifies that the machines are automatically selected for update based on UpdateConfiguration.
551+
OrchestrationTypeAuto OrchestrationType = "Auto"
552+
// OrchestrationTypeManual signifies that the user has to select the machines to be updated manually.
553+
OrchestrationTypeManual OrchestrationType = "Manual"
554+
)
555+
525556
// MachineDeploymentStatus is the most recently observed status of the MachineDeployment.
526557
type MachineDeploymentStatus struct {
527558
// The generation observed by the MachineDeployment controller.

pkg/apis/machine/v1alpha1/machinedeployment_types.go

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ type MachineDeploymentStrategy struct {
113113
// to be.
114114
// +optional
115115
RollingUpdate *RollingUpdateMachineDeployment `json:"rollingUpdate,omitempty"`
116+
117+
// InPlaceUpdate update config params. Present only if MachineDeploymentStrategyType =
118+
// InPlaceUpdate.
119+
// +optional
120+
InPlaceUpdate *InPlaceUpdateMachineDeployment `json:"inPlaceUpdate,omitempty"`
116121
}
117122

118123
// MachineDeploymentStrategyType are valid strategy types for rolling MachineDeployments
@@ -124,16 +129,33 @@ const (
124129

125130
// RollingUpdateMachineDeploymentStrategyType means that old MCs will be replaced by new one using rolling update i.e gradually scale down the old MCs and scale up the new one.
126131
RollingUpdateMachineDeploymentStrategyType MachineDeploymentStrategyType = "RollingUpdate"
132+
133+
// InPlaceUpdateMachineDeploymentStrategyType signifies that VMs will be updated in place and
134+
// machine objects will gradually transition from the old MachineSet to the new MachineSet without requiring VM recreation.
135+
InPlaceUpdateMachineDeploymentStrategyType MachineDeploymentStrategyType = "InPlaceUpdate"
127136
)
128137

129138
// RollingUpdateMachineDeployment is the spec to control the desired behavior of rolling update.
130139
type RollingUpdateMachineDeployment struct {
140+
UpdateConfiguration `json:",inline"`
141+
}
142+
143+
// InPlaceUpdateMachineDeployment specifies the spec to control the desired behavior of inplace update.
144+
type InPlaceUpdateMachineDeployment struct {
145+
UpdateConfiguration `json:",inline"`
146+
147+
// OrchestrationType specifies the orchestration type for the inplace update.
148+
OrchestrationType OrchestrationType `json:"orchestrationType,omitempty"`
149+
}
150+
151+
// UpdateConfiguration specifies the udpate configuration for the deployment strategy.
152+
type UpdateConfiguration struct {
131153
// The maximum number of machines that can be unavailable during the update.
132154
// Value can be an absolute number (ex: 5) or a percentage of desired machines (ex: 10%).
133155
// Absolute number is calculated from percentage by rounding down.
134156
// This can not be 0 if MaxSurge is 0.
135157
// Example: when this is set to 30%, the old machine set can be scaled down to 70% of desired machines
136-
// immediately when the rolling update starts. Once new machines are ready, old machine set
158+
// immediately when the update starts. Once new machines are ready, old machine set
137159
// can be scaled down further, followed by scaling up the new machine set, ensuring
138160
// that the total number of machines available at all times during the update is at
139161
// least 70% of desired machines.
@@ -146,14 +168,24 @@ type RollingUpdateMachineDeployment struct {
146168
// This can not be 0 if MaxUnavailable is 0.
147169
// Absolute number is calculated from percentage by rounding up.
148170
// Example: when this is set to 30%, the new machine set can be scaled up immediately when
149-
// the rolling update starts, such that the total number of old and new machines does not exceed
171+
// the update starts, such that the total number of old and new machines does not exceed
150172
// 130% of desired machines. Once old machines have been killed,
151173
// new machine set can be scaled up further, ensuring that total number of machines running
152174
// at any time during the update is utmost 130% of desired machines.
153175
// +optional
154176
MaxSurge *intstr.IntOrString `json:"maxSurge,omitempty"`
155177
}
156178

179+
// OrchestrationType specifies the orchestration type for the inplace update.
180+
type OrchestrationType string
181+
182+
const (
183+
// OrchestrationTypeAuto signifies that the machines are automatically selected for update based on UpdateConfiguration.
184+
OrchestrationTypeAuto OrchestrationType = "Auto"
185+
// OrchestrationTypeManual signifies that the user has to select the machines to be updated manually.
186+
OrchestrationTypeManual OrchestrationType = "Manual"
187+
)
188+
157189
// MachineDeploymentStatus is the most recently observed status of the MachineDeployment.
158190
type MachineDeploymentStatus struct {
159191
// The generation observed by the MachineDeployment controller.

0 commit comments

Comments
 (0)