Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GEP 31] Introduce API changes for supporting InPlaceUpdate #962

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions docs/documents/apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,60 @@ Kubernetes meta/v1.Time
</tbody>
</table>
<br>
<h3 id="machine.sapcloud.io/v1alpha1.InPlaceUpdateMachineDeployment">
<b>InPlaceUpdateMachineDeployment</b>
</h3>
<p>
(<em>Appears on:</em>
<a href="#machine.sapcloud.io/v1alpha1.MachineDeploymentStrategy">MachineDeploymentStrategy</a>)
</p>
<p>
<p>InPlaceUpdateMachineDeployment specifies the spec to control the desired behavior of inplace rolling update.</p>
</p>
<table>
<thead>
<tr>
<th>Field</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>UpdateConfiguration</code>
</td>
<td>
<em>
<a href="#machine.sapcloud.io/v1alpha1.UpdateConfiguration">
UpdateConfiguration
</a>
</em>
</td>
<td>
<p>
(Members of <code>UpdateConfiguration</code> are embedded into this type.)
</p>
</td>
</tr>
<tr>
<td>
<code>orchestrationType</code>
</td>
<td>
<em>
<a href="#machine.sapcloud.io/v1alpha1.OrchestrationType">
OrchestrationType
</a>
</em>
</td>
<td>
<p>OrchestrationType specifies the orchestration type for the inplace update.</p>
</td>
</tr>
</tbody>
</table>
<br>
<h3 id="machine.sapcloud.io/v1alpha1.LastOperation">
<b>LastOperation</b>
</h3>
Expand Down Expand Up @@ -1525,6 +1579,23 @@ RollingUpdateMachineDeployment
to be.</p>
</td>
</tr>
<tr>
<td>
<code>inPlaceUpdate</code>
</td>
<td>
<em>
<a href="#machine.sapcloud.io/v1alpha1.InPlaceUpdateMachineDeployment">
InPlaceUpdateMachineDeployment
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>InPlaceUpdate update config params. Present only if MachineDeploymentStrategyType =
InPlaceUpdate.</p>
</td>
</tr>
</tbody>
</table>
<br>
Expand Down Expand Up @@ -2535,6 +2606,17 @@ see: <a href="https://issues.k8s.io/61966">https://issues.k8s.io/61966</a></p>
</tbody>
</table>
<br>
<h3 id="machine.sapcloud.io/v1alpha1.OrchestrationType">
<b>OrchestrationType</b>
(<code>string</code> alias)</p></h3>
<p>
(<em>Appears on:</em>
<a href="#machine.sapcloud.io/v1alpha1.InPlaceUpdateMachineDeployment">InPlaceUpdateMachineDeployment</a>)
</p>
<p>
<p>OrchestrationType specifies the orchestration type for the inplace update.</p>
</p>
<br>
<h3 id="machine.sapcloud.io/v1alpha1.RollbackConfig">
<b>RollbackConfig</b>
</h3>
Expand Down Expand Up @@ -2592,6 +2674,46 @@ int64
<tbody>
<tr>
<td>
<code>UpdateConfiguration</code>
</td>
<td>
<em>
<a href="#machine.sapcloud.io/v1alpha1.UpdateConfiguration">
UpdateConfiguration
</a>
</em>
</td>
<td>
<p>
(Members of <code>UpdateConfiguration</code> are embedded into this type.)
</p>
</td>
</tr>
</tbody>
</table>
<br>
<h3 id="machine.sapcloud.io/v1alpha1.UpdateConfiguration">
<b>UpdateConfiguration</b>
</h3>
<p>
(<em>Appears on:</em>
<a href="#machine.sapcloud.io/v1alpha1.InPlaceUpdateMachineDeployment">InPlaceUpdateMachineDeployment</a>,
<a href="#machine.sapcloud.io/v1alpha1.RollingUpdateMachineDeployment">RollingUpdateMachineDeployment</a>)
</p>
<p>
<p>UpdateConfiguration specifies the udpate configuration for the rolling strategy.</p>
</p>
<table>
<thead>
<tr>
<th>Field</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>maxUnavailable</code>
</td>
<td>
Expand Down
41 changes: 41 additions & 0 deletions kubernetes/crds/machine.sapcloud.io_machinedeployments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,47 @@ spec:
description: The MachineDeployment strategy to use to replace existing
machines with new ones.
properties:
inPlaceUpdate:
description: |-
InPlaceUpdate update config params. Present only if MachineDeploymentStrategyType =
InPlaceUpdate.
properties:
maxSurge:
anyOf:
- type: integer
- type: string
description: |-
The maximum number of machines that can be scheduled above the desired number of
machines.
Value can be an absolute number (ex: 5) or a percentage of desired machines (ex: 10%).
This can not be 0 if MaxUnavailable is 0.
Absolute number is calculated from percentage by rounding up.
Example: when this is set to 30%, the new machine set can be scaled up immediately when
the rolling update starts, such that the total number of old and new machines does not exceed
130% of desired machines. Once old machines have been killed,
new machine set can be scaled up further, ensuring that total number of machines running
at any time during the update is utmost 130% of desired machines.
x-kubernetes-int-or-string: true
maxUnavailable:
anyOf:
- type: integer
- type: string
description: |-
The maximum number of machines that can be unavailable during the update.
Value can be an absolute number (ex: 5) or a percentage of desired machines (ex: 10%).
Absolute number is calculated from percentage by rounding down.
This can not be 0 if MaxSurge is 0.
Example: when this is set to 30%, the old machine set can be scaled down to 70% of desired machines
immediately when the rolling update starts. Once new machines are ready, old machine set
can be scaled down further, followed by scaling up the new machine set, ensuring
that the total number of machines available at all times during the update is at
least 70% of desired machines.
x-kubernetes-int-or-string: true
orchestrationType:
description: OrchestrationType specifies the orchestration
type for the inplace update.
type: string
type: object
rollingUpdate:
description: |-
Rolling update config params. Present only if MachineDeploymentStrategyType =
Expand Down
31 changes: 31 additions & 0 deletions pkg/apis/machine/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,10 @@ type MachineDeploymentStrategy struct {
// TODO: Update this to follow our convention for oneOf, whatever we decide it
// to be.
RollingUpdate *RollingUpdateMachineDeployment

// InPlaceUpdate update config params. Present only if MachineDeploymentStrategyType =
// InPlaceUpdate.
InPlaceUpdate *InPlaceUpdateMachineDeployment
}

// MachineDeploymentStrategyType is the strategy to be used for rolling a MachineDeployment
Expand All @@ -492,10 +496,27 @@ const (

// 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.
RollingUpdateMachineDeploymentStrategyType MachineDeploymentStrategyType = "RollingUpdate"

// InPlaceUpdateMachineDeploymentStrategyType signifies that machines will be updated in place,
// gradually transitioning from the old MachineSet to the new MachineSet without requiring machine recreation.
InPlaceUpdateMachineDeploymentStrategyType MachineDeploymentStrategyType = "InPlaceUpdate"
)

// RollingUpdateMachineDeployment specifies the spec to control the desired behavior of rolling update.
type RollingUpdateMachineDeployment struct {
UpdateConfiguration
}

// InPlaceUpdateMachineDeployment specifies the spec to control the desired behavior of inplace rolling update.
type InPlaceUpdateMachineDeployment struct {
UpdateConfiguration

// OrchestrationType specifies the orchestration type for the inplace update.
OrchestrationType OrchestrationType
acumino marked this conversation as resolved.
Show resolved Hide resolved
}

// UpdateConfiguration specifies the udpate configuration for the rolling strategy.
type UpdateConfiguration struct {
// The maximum number of machines that can be unavailable during the update.
// Value can be an absolute number (ex: 5) or a percentage of desired machines (ex: 10%).
// Absolute number is calculated from percentage by rounding down.
Expand All @@ -522,6 +543,16 @@ type RollingUpdateMachineDeployment struct {
MaxSurge *intstr.IntOrString
}

// OrchestrationType specifies the orchestration type for the inplace update.
type OrchestrationType string

const (
// OrchestrationTypeAuto signifies that the machines are selected automatically based on MaxUnavailable for being updated.
OrchestrationTypeAuto OrchestrationType = "Auto"
// OrchestrationTypeManual signifies that the user has to select the machines to be updated manually.
OrchestrationTypeManual OrchestrationType = "Manual"
)

// MachineDeploymentStatus is the most recently observed status of the MachineDeployment.
type MachineDeploymentStatus struct {
// The generation observed by the MachineDeployment controller.
Expand Down
32 changes: 32 additions & 0 deletions pkg/apis/machine/v1alpha1/machinedeployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ type MachineDeploymentStrategy struct {
// to be.
// +optional
RollingUpdate *RollingUpdateMachineDeployment `json:"rollingUpdate,omitempty"`

// InPlaceUpdate update config params. Present only if MachineDeploymentStrategyType =
// InPlaceUpdate.
// +optional
InPlaceUpdate *InPlaceUpdateMachineDeployment `json:"inPlaceUpdate,omitempty"`
}

// MachineDeploymentStrategyType are valid strategy types for rolling MachineDeployments
Expand All @@ -124,10 +129,27 @@ const (

// 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.
RollingUpdateMachineDeploymentStrategyType MachineDeploymentStrategyType = "RollingUpdate"

// InPlaceUpdateMachineDeploymentStrategyType signifies that machines will be updated in place,
// gradually transitioning from the old MachineSet to the new MachineSet without requiring machine recreation.
InPlaceUpdateMachineDeploymentStrategyType MachineDeploymentStrategyType = "InPlaceUpdate"
)

// RollingUpdateMachineDeployment is the spec to control the desired behavior of rolling update.
type RollingUpdateMachineDeployment struct {
UpdateConfiguration `json:",inline"`
}

// InPlaceUpdateMachineDeployment specifies the spec to control the desired behavior of inplace rolling update.
type InPlaceUpdateMachineDeployment struct {
UpdateConfiguration `json:",inline"`

// OrchestrationType specifies the orchestration type for the inplace update.
OrchestrationType OrchestrationType `json:"orchestrationType,omitempty"`
}

// UpdateConfiguration specifies the udpate configuration for the rolling strategy.
type UpdateConfiguration struct {
// The maximum number of machines that can be unavailable during the update.
// Value can be an absolute number (ex: 5) or a percentage of desired machines (ex: 10%).
// Absolute number is calculated from percentage by rounding down.
Expand All @@ -154,6 +176,16 @@ type RollingUpdateMachineDeployment struct {
MaxSurge *intstr.IntOrString `json:"maxSurge,omitempty"`
}

// OrchestrationType specifies the orchestration type for the inplace update.
type OrchestrationType string

const (
// OrchestrationTypeAuto signifies that the machines are selected automatically based on MaxUnavailable for being updated.
OrchestrationTypeAuto OrchestrationType = "Auto"
// OrchestrationTypeManual signifies that the user has to select the machines to be updated manually.
OrchestrationTypeManual OrchestrationType = "Manual"
)

// MachineDeploymentStatus is the most recently observed status of the MachineDeployment.
type MachineDeploymentStatus struct {
// The generation observed by the MachineDeployment controller.
Expand Down
24 changes: 22 additions & 2 deletions pkg/apis/machine/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,28 @@ var (
AddToScheme = SchemeBuilder.AddToScheme
)

// GroupName is the group name use in this package
const GroupName = "machine.sapcloud.io"
const (
// GroupName is the group name use in this package
GroupName = "machine.sapcloud.io"

// AnnotationKeyMachineUpdateFailedReason is the annotation key for the machine indicating the reason for the machine update failure.
AnnotationKeyMachineUpdateFailedReason = "node.machine.sapcloud.io/update-failed-reason"

// LabelKeyMachineCandidateForUpdate is the label key for the machine indicating the machine will undergo an update.
LabelKeyMachineCandidateForUpdate = "node.machine.sapcloud.io/candidate-for-update"
// LabelKeyMachineSelectedForUpdate is the label key for the machine indicating the machine is selected for update.
LabelKeyMachineSelectedForUpdate = "node.machine.sapcloud.io/selected-for-update"
// LabelKeyMachineReadyForUpdate is the label key for the machine indicating the machine is ready for update after the node drain.
LabelKeyMachineReadyForUpdate = "node.machine.sapcloud.io/ready-for-update"
// LabelKeyMachineDrainSuccessful is the label key for the machine indicating the node drain was successful.
LabelKeyMachineDrainSuccessful = "node.machine.sapcloud.io/drain-successful"
// LabelKeyMachineUpdateSuccessful is the label key for the machine indicating the machine update was successful.
LabelKeyMachineUpdateSuccessful = "node.machine.sapcloud.io/update-successful"
// LabelKeyMachineUpdateFailed is the label key for the machine indicating the machine update failed.
LabelKeyMachineUpdateFailed = "node.machine.sapcloud.io/update-failed"
// LabelKeyMachineSetSkipUpdate is the label key for the machine indicating the machine set update should be skipped.
LabelKeyMachineSetSkipUpdate = "node.machine.sapcloud.io/machine-set-skip-update"
)
acumino marked this conversation as resolved.
Show resolved Hide resolved

// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}
Expand Down
Loading