Skip to content

Commit

Permalink
Add LifecycleHooks to Machine spec
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelSpeed committed Nov 22, 2021
1 parent 0024a34 commit de5bac2
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 5 deletions.
36 changes: 36 additions & 0 deletions machine/v1beta1/0000_10_machine.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,42 @@ spec:
description: MachineSpec defines the desired state of Machine
type: object
properties:
lifecycleHooks:
description: LifecycleHooks allow users to pause operations on the machine at certain predefined points within the machine lifecycle.
type: object
properties:
preDrain:
description: PreDrain hooks prevent the machine from being drained. This also blocks further lifecycle events, such as termination.
type: array
items:
description: LifecycleHook represents a single instance of a lifecycle hook
type: object
properties:
name:
description: Name defines a unique name for the lifcycle hook. The name should be unique and descriptive, ideally 1-3 words, in CamelCase with no spaces. Names must be unique and should only be managed by a single entity.
type: string
maxLength: 256
minLength: 3
pattern: '[A-Za-z]+'
owner:
description: Owner defines the owner of the lifecycle hook. This should be descriptive enough so that users can identify who/what is responsible for blocking the lifecycle. This could be the name of a controller (e.g. clusteroperator/etcd) or an administrator managing the hook.
type: string
preTerminate:
description: PreTerminate hooks prevent the machine from being terminated. PreTerminate hooks be actioned after the Machine has been drained.
type: array
items:
description: LifecycleHook represents a single instance of a lifecycle hook
type: object
properties:
name:
description: Name defines a unique name for the lifcycle hook. The name should be unique and descriptive, ideally 1-3 words, in CamelCase with no spaces. Names must be unique and should only be managed by a single entity.
type: string
maxLength: 256
minLength: 3
pattern: '[A-Za-z]+'
owner:
description: Owner defines the owner of the lifecycle hook. This should be descriptive enough so that users can identify who/what is responsible for blocking the lifecycle. This could be the name of a controller (e.g. clusteroperator/etcd) or an administrator managing the hook.
type: string
metadata:
description: ObjectMeta will autopopulate the Node created. Use this to indicate what labels, annotations, name prefix, etc., should be used when creating the Node.
type: object
Expand Down
36 changes: 36 additions & 0 deletions machine/v1beta1/0000_10_machineset.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,42 @@ spec:
description: 'Specification of the desired behavior of the machine. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status'
type: object
properties:
lifecycleHooks:
description: LifecycleHooks allow users to pause operations on the machine at certain predefined points within the machine lifecycle.
type: object
properties:
preDrain:
description: PreDrain hooks prevent the machine from being drained. This also blocks further lifecycle events, such as termination.
type: array
items:
description: LifecycleHook represents a single instance of a lifecycle hook
type: object
properties:
name:
description: Name defines a unique name for the lifcycle hook. The name should be unique and descriptive, ideally 1-3 words, in CamelCase with no spaces. Names must be unique and should only be managed by a single entity.
type: string
maxLength: 256
minLength: 3
pattern: '[A-Za-z]+'
owner:
description: Owner defines the owner of the lifecycle hook. This should be descriptive enough so that users can identify who/what is responsible for blocking the lifecycle. This could be the name of a controller (e.g. clusteroperator/etcd) or an administrator managing the hook.
type: string
preTerminate:
description: PreTerminate hooks prevent the machine from being terminated. PreTerminate hooks be actioned after the Machine has been drained.
type: array
items:
description: LifecycleHook represents a single instance of a lifecycle hook
type: object
properties:
name:
description: Name defines a unique name for the lifcycle hook. The name should be unique and descriptive, ideally 1-3 words, in CamelCase with no spaces. Names must be unique and should only be managed by a single entity.
type: string
maxLength: 256
minLength: 3
pattern: '[A-Za-z]+'
owner:
description: Owner defines the owner of the lifecycle hook. This should be descriptive enough so that users can identify who/what is responsible for blocking the lifecycle. This could be the name of a controller (e.g. clusteroperator/etcd) or an administrator managing the hook.
type: string
metadata:
description: ObjectMeta will autopopulate the Node created. Use this to indicate what labels, annotations, name prefix, etc., should be used when creating the Node.
type: object
Expand Down
39 changes: 39 additions & 0 deletions machine/v1beta1/types_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ type MachineSpec struct {
// +optional
ObjectMeta `json:"metadata,omitempty"`

// LifecycleHooks allow users to pause operations on the machine at
// certain predefined points within the machine lifecycle.
// +optional
LifecycleHooks LifecycleHooks `json:"lifecycleHooks,omitempty"`

// The list of the taints to be applied to the corresponding Node in additive
// manner. This list will not overwrite any other taints added to the Node on
// an ongoing basis by other entities. These taints should be actively reconciled
Expand Down Expand Up @@ -194,6 +199,40 @@ type MachineSpec struct {
ProviderID *string `json:"providerID,omitempty"`
}

// LifecycleHooks allow users to pause operations on the machine at
// certain prefedined points within the machine lifecycle.
type LifecycleHooks struct {
// PreDrain hooks prevent the machine from being drained.
// This also blocks further lifecycle events, such as termination.
// +optional
PreDrain []LifecycleHook `json:"preDrain,omitempty"`

// PreTerminate hooks prevent the machine from being terminated.
// PreTerminate hooks be actioned after the Machine has been drained.
// +optional
PreTerminate []LifecycleHook `json:"preTerminate,omitempty"`
}

// LifecycleHook represents a single instance of a lifecycle hook
type LifecycleHook struct {
// Name defines a unique name for the lifcycle hook.
// The name should be unique and descriptive, ideally 1-3 words, in CamelCase with no spaces.
// Names must be unique and should only be managed by a single entity.
// +kubebuilder:validation:Pattern:="[A-Za-z]+"
// +kubebuilder:validation:MinLength:=3
// +kubebuilder:validation:MaxLength:=256
// +required
Name string `json:"name"`

// Owner defines the owner of the lifecycle hook.
// This should be descriptive enough so that users can identify
// who/what is responsible for blocking the lifecycle.
// This could be the name of a controller (e.g. clusteroperator/etcd)
// or an administrator managing the hook.
// +required
Owner string `json:"owner"`
}

// MachineStatus defines the observed state of Machine
type MachineStatus struct {
// NodeRef will point to the corresponding Node if it exists.
Expand Down
43 changes: 43 additions & 0 deletions machine/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 26 additions & 5 deletions machine/v1beta1/zz_generated.swagger_doc_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit de5bac2

Please sign in to comment.