@@ -6,149 +6,114 @@ import (
66 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
77)
88
9- // CocoonSetSpec is the desired state of a CocoonSet.
109type CocoonSetSpec struct {
11- // Suspend, when true, hibernates every managed pod.
1210 // +optional
1311 Suspend bool `json:"suspend,omitempty"`
1412
15- // SnapshotPolicy controls when vk-cocoon snapshots VMs before destroying them.
1613 // +optional
1714 // +kubebuilder:default=always
1815 SnapshotPolicy SnapshotPolicy `json:"snapshotPolicy,omitempty"`
1916
20- // NodePool selects the cocoon node pool that should host this CocoonSet.
21- // vk-cocoon nodes are labeled with cocoonstack.io/pool=<name>.
2217 // +optional
2318 // +kubebuilder:default=default
2419 NodePool string `json:"nodePool,omitempty"`
2520
26- // Agent describes the main agent VM and any sub-agent replicas.
2721 // +kubebuilder:validation:Required
2822 Agent AgentSpec `json:"agent"`
2923
30- // Toolboxes are companion VMs scheduled alongside the agents.
3124 // +optional
3225 Toolboxes []ToolboxSpec `json:"toolboxes,omitempty"`
3326}
3427
35- // AgentSpec describes a CocoonSet's main agent and sub-agent replicas.
3628type AgentSpec struct {
37- // Replicas is the number of sub-agents to fork from the main agent.
38- // The main agent is always created in addition to Replicas.
29+ // Replicas is the number of sub-agents; the main agent is always created in addition.
3930 // +optional
4031 // +kubebuilder:default=0
4132 // +kubebuilder:validation:Minimum=0
4233 Replicas int32 `json:"replicas,omitempty"`
4334
44- // Image is the epoch reference or boot image URL.
4535 // +kubebuilder:validation:Required
4636 // +kubebuilder:validation:MinLength=1
4737 Image string `json:"image"`
4838
49- // Mode controls how the VM is brought up.
5039 // +optional
5140 // +kubebuilder:default=clone
5241 Mode AgentMode `json:"mode,omitempty"`
5342
54- // OS is the guest operating system.
5543 // +optional
5644 // +kubebuilder:default=linux
5745 OS OSType `json:"os,omitempty"`
5846
59- // Network is the CNI conflist name to use; empty means cocoon default.
6047 // +optional
6148 Network string `json:"network,omitempty"`
6249
63- // Storage is the COW disk size to allocate for each VM.
6450 // +optional
6551 Storage * resource.Quantity `json:"storage,omitempty"`
6652
67- // Resources passes through CPU/memory hints to the underlying pod.
6853 // +optional
6954 Resources corev1.ResourceRequirements `json:"resources,omitempty"`
7055
71- // EnvFrom is forwarded to the agent container's envFrom field.
7256 // +optional
7357 EnvFrom []corev1.EnvFromSource `json:"envFrom,omitempty"`
7458
75- // ServiceAccountName overrides the agent pod's serviceAccountName.
7659 // +optional
7760 ServiceAccountName string `json:"serviceAccountName,omitempty"`
7861}
7962
80- // ToolboxSpec describes a companion toolbox VM scheduled alongside agents.
8163type ToolboxSpec struct {
82- // Name is unique within the CocoonSet and must follow RFC 1123 label rules.
8364 // +kubebuilder:validation:Required
8465 // +kubebuilder:validation:MinLength=1
8566 // +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`
8667 Name string `json:"name"`
8768
88- // OS is the guest operating system.
8969 // +optional
9070 // +kubebuilder:default=linux
9171 OS OSType `json:"os,omitempty"`
9272
93- // Image is the epoch reference or boot image URL. Required for non-static modes.
9473 // +optional
9574 Image string `json:"image,omitempty"`
9675
97- // Mode controls how the toolbox VM is brought up.
9876 // +optional
9977 // +kubebuilder:default=run
10078 Mode ToolboxMode `json:"mode,omitempty"`
10179
102- // Storage is the COW disk size to allocate.
10380 // +optional
10481 Storage * resource.Quantity `json:"storage,omitempty"`
10582
106- // StaticIP is the pre-assigned IP for static-mode toolboxes.
10783 // +optional
10884 StaticIP string `json:"staticIP,omitempty"`
10985
110- // StaticVMID is the pre-assigned VM identifier for static-mode toolboxes.
11186 // +optional
11287 StaticVMID string `json:"staticVMID,omitempty"`
11388
114- // VNCPort is the VNC port for graphical access (Windows, Android).
11589 // +optional
11690 // +kubebuilder:validation:Minimum=0
11791 // +kubebuilder:validation:Maximum=65535
11892 VNCPort int32 `json:"vncPort,omitempty"`
11993
120- // Resources passes through CPU/memory hints to the underlying pod.
12194 // +optional
12295 Resources corev1.ResourceRequirements `json:"resources,omitempty"`
12396}
12497
125- // CocoonSetStatus is the observed state of a CocoonSet.
12698type CocoonSetStatus struct {
127- // ObservedGeneration is the .metadata.generation the controller last reconciled.
12899 // +optional
129100 ObservedGeneration int64 `json:"observedGeneration,omitempty"`
130101
131- // Phase is the high-level lifecycle phase.
132102 // +optional
133103 Phase CocoonSetPhase `json:"phase,omitempty"`
134104
135- // ReadyAgents is the count of agent pods in the Running phase.
136105 // +optional
137106 ReadyAgents int32 `json:"readyAgents"`
138107
139- // DesiredAgents is the total number of agents requested by spec (1 + Replicas).
140108 // +optional
141109 DesiredAgents int32 `json:"desiredAgents"`
142110
143- // Agents reports per-agent runtime state.
144111 // +optional
145112 Agents []AgentStatus `json:"agents,omitempty"`
146113
147- // Toolboxes reports per-toolbox runtime state.
148114 // +optional
149115 Toolboxes []ToolboxStatus `json:"toolboxes,omitempty"`
150116
151- // Conditions follow the standard Kubernetes condition pattern.
152117 // +optional
153118 // +patchMergeKey=type
154119 // +patchStrategy=merge
@@ -157,9 +122,6 @@ type CocoonSetStatus struct {
157122 Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
158123}
159124
160- // AgentStatus is the per-agent runtime state. Slot 0 is always the
161- // main agent; ForkedFrom is set only for sub-agents and points at
162- // the main VM they cloned from.
163125type AgentStatus struct {
164126 Slot int32 `json:"slot"`
165127 Role string `json:"role"`
@@ -171,9 +133,6 @@ type AgentStatus struct {
171133 ForkedFrom string `json:"forkedFrom,omitempty"`
172134}
173135
174- // ToolboxStatus is the per-toolbox runtime state. ConnType is the
175- // preferred kubectl-style connection protocol picked by
176- // meta.ConnectionType (ssh / rdp / adb / vnc).
177136type ToolboxStatus struct {
178137 Name string `json:"name"`
179138 PodName string `json:"podName,omitempty"`
@@ -193,7 +152,6 @@ type ToolboxStatus struct {
193152// +kubebuilder:printcolumn:name="Desired",type=integer,JSONPath=`.status.desiredAgents`
194153// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
195154
196- // CocoonSet is the Schema for the cocoonsets API.
197155type CocoonSet struct {
198156 metav1.TypeMeta `json:",inline"`
199157 metav1.ObjectMeta `json:"metadata,omitempty"`
@@ -204,7 +162,6 @@ type CocoonSet struct {
204162
205163// +kubebuilder:object:root=true
206164
207- // CocoonSetList is a list of CocoonSet.
208165type CocoonSetList struct {
209166 metav1.TypeMeta `json:",inline"`
210167 metav1.ListMeta `json:"metadata,omitempty"`
0 commit comments