|
| 1 | +package v1alpha1 |
| 2 | + |
| 3 | +import ( |
| 4 | + corev1 "k8s.io/api/core/v1" |
| 5 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 6 | +) |
| 7 | + |
| 8 | +type RuntimeBackend string |
| 9 | + |
| 10 | +const RuntimeBackendCRI RuntimeBackend = "cri" |
| 11 | + |
| 12 | +type CRIRuntimeConfig struct { |
| 13 | + // RuntimeHandler is the CRI runtime handler name configured in the Worker's |
| 14 | + // containerd. It is an opaque string (for example "runsc" or "runc"); |
| 15 | + // SandboxFleet does not interpret runtime-specific values. |
| 16 | + // +kubebuilder:validation:MinLength=1 |
| 17 | + RuntimeHandler string `json:"runtimeHandler"` |
| 18 | +} |
| 19 | + |
| 20 | +// +kubebuilder:validation:XValidation:rule="self.backend != 'cri' || has(self.cri)",message="cri configuration is required for the cri backend" |
| 21 | +type RuntimeConfig struct { |
| 22 | + // +kubebuilder:validation:Enum=cri |
| 23 | + Backend RuntimeBackend `json:"backend"` |
| 24 | + |
| 25 | + // +optional |
| 26 | + CRI *CRIRuntimeConfig `json:"cri,omitempty"` |
| 27 | +} |
| 28 | + |
| 29 | +// SandboxPoolSpec defines a homogeneous group of Workers. |
| 30 | +type SandboxPoolSpec struct { |
| 31 | + // +kubebuilder:validation:Minimum=0 |
| 32 | + Workers int32 `json:"workers"` |
| 33 | + |
| 34 | + // +kubebuilder:validation:Minimum=1 |
| 35 | + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="slotsPerWorker is immutable" |
| 36 | + SlotsPerWorker int32 `json:"slotsPerWorker"` |
| 37 | + |
| 38 | + // SlotResources is the resource budget for each Slot. |
| 39 | + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="slotResources is immutable" |
| 40 | + SlotResources corev1.ResourceRequirements `json:"slotResources,omitempty"` |
| 41 | + |
| 42 | + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="runtime is immutable" |
| 43 | + Runtime RuntimeConfig `json:"runtime"` |
| 44 | +} |
| 45 | + |
| 46 | +type SandboxPoolStatus struct { |
| 47 | + ObservedGeneration int64 `json:"observedGeneration,omitempty"` |
| 48 | + CurrentWorkers int32 `json:"currentWorkers,omitempty"` |
| 49 | + ReadyWorkers int32 `json:"readyWorkers,omitempty"` |
| 50 | + UsedSlots int32 `json:"usedSlots,omitempty"` |
| 51 | + AvailableSlots int32 `json:"availableSlots,omitempty"` |
| 52 | + Conditions []metav1.Condition `json:"conditions,omitempty"` |
| 53 | +} |
| 54 | + |
| 55 | +// +kubebuilder:object:root=true |
| 56 | +// +kubebuilder:subresource:status |
| 57 | +// +kubebuilder:resource:scope=Namespaced,shortName=sfp |
| 58 | +// +kubebuilder:printcolumn:name="Workers",type=integer,JSONPath=`.status.currentWorkers` |
| 59 | +// +kubebuilder:printcolumn:name="Ready",type=integer,JSONPath=`.status.readyWorkers` |
| 60 | +// +kubebuilder:printcolumn:name="Available",type=integer,JSONPath=`.status.availableSlots` |
| 61 | +type SandboxPool struct { |
| 62 | + metav1.TypeMeta `json:",inline"` |
| 63 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 64 | + |
| 65 | + Spec SandboxPoolSpec `json:"spec"` |
| 66 | + Status SandboxPoolStatus `json:"status,omitempty"` |
| 67 | +} |
| 68 | + |
| 69 | +// +kubebuilder:object:root=true |
| 70 | +type SandboxPoolList struct { |
| 71 | + metav1.TypeMeta `json:",inline"` |
| 72 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 73 | + Items []SandboxPool `json:"items"` |
| 74 | +} |
| 75 | + |
| 76 | +func init() { |
| 77 | + SchemeBuilder.Register(&SandboxPool{}, &SandboxPoolList{}) |
| 78 | +} |
0 commit comments