Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions apis/v1/cocoonset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ type CocoonSetSpec struct {
// +kubebuilder:default=default
NodePool string `json:"nodePool,omitempty"`

// NodeName pins the VM to a node (cross-node migrate). Empty = let the
// scheduler place it within NodePool and leave it alone; a value adds a
// hostname nodeAffinity so the pod lands there or stays Pending if it won't fit.
// +optional
NodeName string `json:"nodeName,omitempty"`

// +kubebuilder:validation:Required
Agent AgentSpec `json:"agent"`

Expand Down
9 changes: 9 additions & 0 deletions apis/v1/crds/cocoonset.cocoonstack.io_cocoonsets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ spec:
- linux
- windows
- android
- macos
type: string
probePort:
description: ProbePort overrides the default ICMP probe with a
Expand Down Expand Up @@ -247,6 +248,12 @@ spec:
required:
- image
type: object
nodeName:
description: |-
NodeName pins the VM to a node (cross-node migrate). Empty = let the
scheduler place it within NodePool and leave it alone; a value adds a
hostname nodeAffinity so the pod lands there or stays Pending if it won't fit.
type: string
nodePool:
default: default
type: string
Expand Down Expand Up @@ -322,6 +329,7 @@ spec:
- linux
- windows
- android
- macos
type: string
probePort:
description: ProbePort overrides the default ICMP probe with
Expand Down Expand Up @@ -522,6 +530,7 @@ spec:
- Scaling
- Suspending
- Suspended
- Migrating
- Failed
type: string
readyAgents:
Expand Down
8 changes: 5 additions & 3 deletions apis/v1/enums.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const (
OSLinux OSType = "linux"
OSWindows OSType = "windows"
OSAndroid OSType = "android"
OSMacos OSType = "macos"

SnapshotPolicyAlways SnapshotPolicy = "always"
SnapshotPolicyMainOnly SnapshotPolicy = "main-only"
Expand All @@ -26,6 +27,7 @@ const (
CocoonSetPhaseScaling CocoonSetPhase = "Scaling"
CocoonSetPhaseSuspending CocoonSetPhase = "Suspending"
CocoonSetPhaseSuspended CocoonSetPhase = "Suspended"
CocoonSetPhaseMigrating CocoonSetPhase = "Migrating"
CocoonSetPhaseFailed CocoonSetPhase = "Failed"

ConnTypeSSH ConnType = "ssh"
Expand All @@ -42,7 +44,7 @@ const (
var (
agentModeValid = []AgentMode{AgentModeClone, AgentModeRun}
toolboxModeValid = []ToolboxMode{ToolboxModeRun, ToolboxModeClone, ToolboxModeStatic}
osTypeValid = []OSType{OSLinux, OSWindows, OSAndroid}
osTypeValid = []OSType{OSLinux, OSWindows, OSAndroid, OSMacos}
snapshotPolicyValid = []SnapshotPolicy{SnapshotPolicyAlways, SnapshotPolicyMainOnly, SnapshotPolicyNever}
connTypeValid = []ConnType{ConnTypeSSH, ConnTypeRDP, ConnTypeVNC, ConnTypeADB}
backendValid = []Backend{BackendCloudHypervisor, BackendFirecracker}
Expand All @@ -57,15 +59,15 @@ type AgentMode string
type ToolboxMode string

// OSType defines the guest operating system type.
// +kubebuilder:validation:Enum=linux;windows;android
// +kubebuilder:validation:Enum=linux;windows;android;macos
type OSType string

// SnapshotPolicy defines when VM snapshots are taken.
// +kubebuilder:validation:Enum=always;main-only;never
type SnapshotPolicy string

// CocoonSetPhase represents the lifecycle phase of a CocoonSet.
// +kubebuilder:validation:Enum=Pending;Running;Scaling;Suspending;Suspended;Failed
// +kubebuilder:validation:Enum=Pending;Running;Scaling;Suspending;Suspended;Migrating;Failed
type CocoonSetPhase string

// ConnType is the connection protocol advertised for a VM. Empty
Expand Down
9 changes: 9 additions & 0 deletions meta/hibernate.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,12 @@ func ReadHibernateState(pod *corev1.Pod) HibernateState {
}
return HibernateState(pod.Annotations[AnnotationHibernate] == annotationTrue)
}

// ReadRestoreFromHibernate reports whether the pod is flagged to restore its VM
// from the :hibernate snapshot instead of cloning from the base image.
func ReadRestoreFromHibernate(pod *corev1.Pod) bool {
if pod == nil {
return false
}
return pod.Annotations[AnnotationRestoreFromHibernate] == annotationTrue
}
4 changes: 4 additions & 0 deletions meta/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ const (
AnnotationVNCPort = "vm.cocoonstack.io/vnc-port"
// AnnotationHibernate signals "hibernate this VM" when set to "true".
AnnotationHibernate = "vm.cocoonstack.io/hibernate"
// AnnotationRestoreFromHibernate signals that a freshly created pod must
// restore its VM from the :hibernate snapshot (cross-node migration) instead
// of cloning from the base image. Written by the operator on the rebuilt pod.
AnnotationRestoreFromHibernate = "vm.cocoonstack.io/restore-from-hibernate"
// AnnotationForkFrom names a VM to fork the new VM from.
AnnotationForkFrom = "vm.cocoonstack.io/fork-from"
// AnnotationCloneFromDir names a host directory to clone the VM image from (vk-cocoon-specific).
Expand Down