[node operator] PendingNode CRD definition

Signed-off-by: Malte Poll <mp@edgeless.systems>
This commit is contained in:
Malte Poll 2022-06-27 11:26:12 +02:00 committed by Malte Poll
parent b36160e8a4
commit 59a9f49fbe
3 changed files with 94 additions and 13 deletions

View File

@ -5,22 +5,64 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
const (
// NodeGoalJoin is the goal to join the cluster.
NodeGoalJoin PendingNodeGoal = "Join"
// NodeGoalLeave is the goal to leave the cluster and terminate the node.
NodeGoalLeave PendingNodeGoal = "Leave"
// NodeStateUnknown is the default state of the node if no information is available.
NodeStateUnknown CSPNodeState = "Unknown"
// NodeStateCreating is the state of the node when it is being created.
NodeStateCreating CSPNodeState = "Creating"
// NodeStateReady is the state of the node when it is ready to use.
// This state is reached when the CSP reports a node to be ready.
// This does not guarantee that a node has already joined the cluster.
NodeStateReady CSPNodeState = "Ready"
// NodeStateStopped is the state of the node when not running temporarily.
NodeStateStopped CSPNodeState = "Stopped"
// NodeStateTerminating is the state of the node when it is being terminated.
NodeStateTerminating CSPNodeState = "Terminating"
// NodeStateTerminated is the state of the node when it is terminated.
NodeStateTerminated CSPNodeState = "Terminated"
// NodeStateFailed is the state of the node when it encounters an unrecoverable error.
NodeStateFailed CSPNodeState = "Failed"
)
// PendingNodeGoal is the desired state of PendingNode.
// Only one of the following goals may be specified.
// +kubebuilder:validation:Enum=Join;Leave
type PendingNodeGoal string
// CSPNodeState is the state of a Node in the cloud.
// Only one of the following states may be specified.
// +kubebuilder:validation:Enum=Unknown;Creating;Ready;Stopped;Terminating;Terminated;Failed
type CSPNodeState string
// PendingNodeSpec defines the desired state of PendingNode
type PendingNodeSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
// Foo is an example field of PendingNode. Edit pendingnode_types.go to remove/update
Foo string `json:"foo,omitempty"`
// ProviderID is the provider ID of the node.
ProviderID string `json:"providerID,omitempty"`
// ScalingGroupID is the ID of the group that this node shall be part of.
ScalingGroupID string `json:"groupID,omitempty"`
// NodeName is the kubernetes internal name of the node.
NodeName string `json:"nodeName,omitempty"`
// Goal is the goal of the pending state.
Goal PendingNodeGoal `json:"goal,omitempty"`
// Deadline is the deadline for reaching the goal state.
// Joining nodes will be terminated if the deadline is exceeded.
// Leaving nodes will remain as unschedulable to prevent data loss.
// If not specified, the node may remain in the pending state indefinitely.
// +optional
Deadline *metav1.Time `json:"deadline,omitempty"`
}
// PendingNodeStatus defines the observed state of PendingNode
type PendingNodeStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
// CSPNodeState is the state of the node in the cloud.
CSPNodeState `json:"cspState,omitempty"`
// ReachedGoal is true if the node has reached the goal state.
ReachedGoal bool `json:"reachedGoal,omitempty"`
}
//+kubebuilder:object:root=true

View File

@ -242,7 +242,7 @@ func (in *PendingNode) DeepCopyInto(out *PendingNode) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
out.Spec = in.Spec
in.Spec.DeepCopyInto(&out.Spec)
out.Status = in.Status
}
@ -299,6 +299,10 @@ func (in *PendingNodeList) DeepCopyObject() runtime.Object {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PendingNodeSpec) DeepCopyInto(out *PendingNodeSpec) {
*out = *in
if in.Deadline != nil {
in, out := &in.Deadline, &out.Deadline
*out = (*in).DeepCopy()
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PendingNodeSpec.

View File

@ -35,13 +35,48 @@ spec:
spec:
description: PendingNodeSpec defines the desired state of PendingNode
properties:
foo:
description: Foo is an example field of PendingNode. Edit pendingnode_types.go
to remove/update
deadline:
description: Deadline is the deadline for reaching the goal state.
Joining nodes will be terminated if the deadline is exceeded. Leaving
nodes will remain as unschedulable to prevent data loss. If not
specified, the node may remain in the pending state indefinitely.
format: date-time
type: string
goal:
description: Goal is the goal of the pending state.
enum:
- Join
- Leave
type: string
groupID:
description: ScalingGroupID is the ID of the group that this node
shall be part of.
type: string
nodeName:
description: NodeName is the kubernetes internal name of the node.
type: string
providerID:
description: ProviderID is the provider ID of the node.
type: string
type: object
status:
description: PendingNodeStatus defines the observed state of PendingNode
properties:
cspState:
description: CSPNodeState is the state of the node in the cloud.
enum:
- Unknown
- Creating
- Ready
- Stopped
- Terminating
- Terminated
- Failed
type: string
reachedGoal:
description: ReachedGoal is true if the node has reached the goal
state.
type: boolean
type: object
type: object
served: true