Skip to content
Open
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
56 changes: 48 additions & 8 deletions api/v1alpha1/flamecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,44 @@
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"

Check failure on line 20 in api/v1alpha1/flamecluster_types.go

View workflow job for this annotation

GitHub Actions / Build

missing go.sum entry for module providing package k8s.io/api/core/v1 (imported by github.com/xflops/flame-operator/api/v1alpha1); to add:

Check failure on line 20 in api/v1alpha1/flamecluster_types.go

View workflow job for this annotation

GitHub Actions / Test

missing go.sum entry for module providing package k8s.io/api/core/v1 (imported by github.com/xflops/flame-operator/api/v1alpha1); to add:
"k8s.io/apimachinery/pkg/api/resource"

Check failure on line 21 in api/v1alpha1/flamecluster_types.go

View workflow job for this annotation

GitHub Actions / Build

missing go.sum entry for module providing package k8s.io/apimachinery/pkg/api/resource (imported by github.com/xflops/flame-operator/api/v1alpha1); to add:

Check failure on line 21 in api/v1alpha1/flamecluster_types.go

View workflow job for this annotation

GitHub Actions / Test

missing go.sum entry for module providing package k8s.io/apimachinery/pkg/api/resource (imported by github.com/xflops/flame-operator/api/v1alpha1); to add:
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

Check failure on line 22 in api/v1alpha1/flamecluster_types.go

View workflow job for this annotation

GitHub Actions / Build

missing go.sum entry for module providing package k8s.io/apimachinery/pkg/apis/meta/v1 (imported by github.com/xflops/flame-operator/api/v1alpha1); to add:

Check failure on line 22 in api/v1alpha1/flamecluster_types.go

View workflow job for this annotation

GitHub Actions / Test

missing go.sum entry for module providing package k8s.io/apimachinery/pkg/apis/meta/v1 (imported by github.com/xflops/flame-operator/api/v1alpha1); to add:
)

// 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.

// SlotSpec defines the resource slot for task scheduling.
// Uses standard Kubernetes resource.Quantity for proper unit handling and validation.
type SlotSpec struct {
// CPU is the CPU resource quantity for the slot.
// +optional
CPU resource.Quantity `json:"cpu,omitempty"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if use Quantity, how we're going to genereate FlameClusterYaml?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. The conversion happens in the controller's Reconcile loop.

We use resource.Quantity in the CRD to leverage Kubernetes' native validation and support user-friendly formats (e.g., 1Gi, 500m).

When generating the FlameClusterYaml (internal config):

  1. The controller reads the resource.Quantity fields.
  2. It calls methods like .Value() (for raw integer) or .String() to convert them into the specific format required by FlameClusterYaml.

This keeps the API user-friendly while ensuring the internal config gets the exact format it needs.


// Memory is the memory resource quantity for the slot.
// +optional
Memory resource.Quantity `json:"memory,omitempty"`

// GPU is the GPU resource quantity for the slot.
// +optional
GPU resource.Quantity `json:"gpu,omitempty"`
}

// StorageConfig defines the storage backend configuration with secure credential handling.
type StorageConfig struct {
// Type is the storage backend type (e.g., "sqlite", "postgres", "mysql").
// +kubebuilder:validation:Enum=sqlite;postgres;mysqlntType string `json:"type"`

// SecretRef is a reference to a secret key containing the connection string or credentials.
// +optional
SecretRef *corev1.SecretKeySelector `json:"secretRef,omitempty"`

// Path is the filesystem path for file-based storage (e.g., SQLite).
// +optional
Path string `json:"path,omitempty"`
}

// FlameClusterSpec defines the desired state of FlameCluster
type FlameClusterSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
Expand All @@ -47,16 +78,21 @@
// Resources defines the compute resource requirements.
Resources corev1.ResourceRequirements `json:"resources,omitempty"`

// Slot defines the resource slot definition (e.g., "cpu=1,mem=1g").
Slot string `json:"slot,omitempty"`
// Slot defines the resource slot for task scheduling.
// +optional
Slot *SlotSpec `json:"slot,omitempty"`

// Policy defines the scheduling policy (e.g., "priority").
// Policy defines the scheduling policy.
// +kubebuilder:validation:Enum=priority;fifo;fair
// +optional
Policy string `json:"policy,omitempty"`

// Storage defines the storage backend URI (e.g., "sqlite://flame.db").
Storage string `json:"storage,omitempty"`
// Storage defines the storage backend configuration.
// +optional
Storage *StorageConfig `json:"storage,omitempty"`
}


// ExecutorManagerSpec defines the configuration for the executor manager
type ExecutorManagerSpec struct {
// Image is the container image to use.
Expand All @@ -69,7 +105,9 @@
// Resources defines the compute resource requirements.
Resources corev1.ResourceRequirements `json:"resources,omitempty"`

// Shim defines the executor shim type (e.g., "host").
// Shim defines the executor shim type.
// +kubebuilder:validation:Enum=host;docker;kubernetes
// +optional
Shim string `json:"shim,omitempty"`

// MaxExecutors is the maximum number of executors per node.
Expand All @@ -82,8 +120,10 @@
// NetworkInterface is the network interface to use for cache communication.
NetworkInterface string `json:"networkInterface,omitempty"`

// Storage defines the storage path for the cache.
Storage string `json:"storage,omitempty"`
// VolumeSource defines the storage volume for the cache.
// Supports EmptyDir, PVC, HostPath, etc. via standard Kubernetes VolumeSource.
// +optional
VolumeSource *corev1.VolumeSource `json:"volumeSource,omitempty"`
}

// FlameClusterStatus defines the observed state of FlameCluster
Expand Down
Loading