Documentation
¶
Index ¶
- Constants
- Variables
- func CopyLabels(kaiwoLabels map[string]string, objectMeta *v1.ObjectMeta)
- func SetKaiwoSystemLabels(kaiwoLabelContext KaiwoLabelContext, objectMeta *v1.ObjectMeta)
- type KaiwoLabelContext
- type KaiwoWorkload
- type LocalQueueReconciler
- type Reconciler
- type ReconcilerBase
- type ResourceReconciler
- type ResourceReconcilerBase
- func (d *ResourceReconcilerBase[T]) Create(ctx context.Context, k8sClient client.Client, scheme *runtime.Scheme, ...) error
- func (d *ResourceReconcilerBase[T]) Get(ctx context.Context, k8sClient client.Client) (actual T, err error)
- func (d *ResourceReconcilerBase[T]) Reconcile(ctx context.Context, k8sClient client.Client, scheme *runtime.Scheme, ...) (actual T, result *ctrl.Result, err error)
- func (d *ResourceReconcilerBase[T]) ShouldContinue(ctx context.Context, actual T) *ctrl.Result
- func (d *ResourceReconcilerBase[T]) Update(_ context.Context, _ client.Client, desired *T, actual T, ...) error
- func (d *ResourceReconcilerBase[T]) ValidateBeforeCreateOrUpdate(ctx context.Context, actual T) (*ctrl.Result, error)
- type StorageReconciler
Constants ¶
View Source
const ( Finalizer = "kaiwo.silogen.ai/finalizer" KaiwoQueueConfigName = "kaiwo" )
View Source
const ( KaiwoLabelBase = "kaiwo.silogen.ai" KaiwoUserLabel = KaiwoLabelBase + "/user" KaiwoNameLabel = KaiwoLabelBase + "/name" KaiwoTypeLabel = KaiwoLabelBase + "/type" KaiwoRunIdLabel = KaiwoLabelBase + "/run-id" KaiwoManagedLabel = KaiwoLabelBase + "/managed" QueueLabel = "kueue.x-k8s.io/queue-name" )
View Source
const ( DataStoragePostfix = "data" HfStoragePostfix = "hf" )
Variables ¶
View Source
var DefaultClusterQueueName = baseutils.GetEnv("DEFAULT_CLUSTER_QUEUE_NAME", "kaiwo")
View Source
var DefaultRequeueDuration = 2 * time.Second
Functions ¶
func CopyLabels ¶
func CopyLabels(kaiwoLabels map[string]string, objectMeta *v1.ObjectMeta)
CopyLabels copies labels from kaiwoLabels to objectMeta.Labels, skipping keys that already exist
func SetKaiwoSystemLabels ¶
func SetKaiwoSystemLabels(kaiwoLabelContext KaiwoLabelContext, objectMeta *v1.ObjectMeta)
SetKaiwoSystemLabels sets the Kaiwo system labels on an ObjectMeta instance
Types ¶
type KaiwoLabelContext ¶
func GetKaiwoLabelContext ¶
func GetKaiwoLabelContext(k KaiwoWorkload) KaiwoLabelContext
type KaiwoWorkload ¶
type KaiwoWorkload interface {
GetUser() string
GetObjectMeta() *metav1.ObjectMeta
GetStatus() string
GetType() string
GetPods(ctx context.Context, k8sClient client.Client) ([]corev1.Pod, error)
GetServices(ctx context.Context, k8sClient client.Client) ([]corev1.Service, error)
GetDuration() *metav1.Duration
GetStartTime() *metav1.Time
GetClusterQueue() string
GetGPUVendor() string
}
type LocalQueueReconciler ¶
type LocalQueueReconciler struct {
ResourceReconcilerBase[*kueuev1beta1.LocalQueue]
}
func NewLocalQueueReconciler ¶
func NewLocalQueueReconciler(objectKey client.ObjectKey) *LocalQueueReconciler
func (*LocalQueueReconciler) Build ¶
func (r *LocalQueueReconciler) Build(_ context.Context, _ client.Client) (*kueuev1beta1.LocalQueue, error)
func (*LocalQueueReconciler) GetEmptyObject ¶
func (r *LocalQueueReconciler) GetEmptyObject() *kueuev1beta1.LocalQueue
type Reconciler ¶
type Reconciler[T client.Object] interface { // Reconcile runs through the reconciliation loop Reconcile(ctx context.Context, k8sClient client.Client, scheme *runtime.Scheme) (ctrl.Result, error) }
Reconciler manages the reconciliation of a Kaiwo resource (job or service)
type ReconcilerBase ¶
type ReconcilerBase[T client.Object] struct { ObjectKey client.ObjectKey Object T Self Reconciler[T] }
type ResourceReconciler ¶
type ResourceReconciler[T client.Object] interface { // Build will build the client object without creating it Build(ctx context.Context, k8sClient client.Client) (desired T, err error) // Get will fetch the client object Get(ctx context.Context, k8sClient client.Client) (actual T, err error) // Create will create the client object Create(ctx context.Context, k8sClient client.Client, scheme *runtime.Scheme, desired T, owner client.Object, recorder record.EventRecorder) error // Update will update the client object Update(ctx context.Context, k8sClient client.Client, desired *T, actual T, recorder record.EventRecorder) error // Reconcile will build and then create Reconcile(ctx context.Context, k8sClient client.Client, scheme *runtime.Scheme, owner client.Object, recorder record.EventRecorder) (actual T, result *ctrl.Result, err error) // ShouldContinue returns a reconciliation result if there is an intermediate result to return ShouldContinue(ctx context.Context, actual T) *ctrl.Result GetEmptyObject() T // ValidateBeforeCreateOrUpdate provides a way to abort the reconciliation based on the currently existing object's state ValidateBeforeCreateOrUpdate(ctx context.Context, actual T) (*ctrl.Result, error) }
ResourceReconciler ensures that a single dependent resource is reconciled to a desired state
type ResourceReconcilerBase ¶
type ResourceReconcilerBase[T client.Object] struct { ObjectKey client.ObjectKey Self ResourceReconciler[T] Desired T }
func (*ResourceReconcilerBase[T]) Reconcile ¶
func (d *ResourceReconcilerBase[T]) Reconcile(ctx context.Context, k8sClient client.Client, scheme *runtime.Scheme, owner client.Object, recorder record.EventRecorder) (actual T, result *ctrl.Result, err error)
Reconcile ensures that the resource exists and is in the desired state. The object is first built based on the reconciler object (kaiwo job or service), and the remote object is fetched. If it exists, it is updated, otherwise it is created.
func (*ResourceReconcilerBase[T]) ShouldContinue ¶
func (d *ResourceReconcilerBase[T]) ShouldContinue(ctx context.Context, actual T) *ctrl.Result
func (*ResourceReconcilerBase[T]) Update ¶
func (d *ResourceReconcilerBase[T]) Update(_ context.Context, _ client.Client, desired *T, actual T, recorder record.EventRecorder) error
Update updates the object. By default, nothing is done, and desired is set to actual
func (*ResourceReconcilerBase[T]) ValidateBeforeCreateOrUpdate ¶
type StorageReconciler ¶
type StorageReconciler struct {
ResourceReconcilerBase[*corev1.PersistentVolumeClaim]
Amount string
StorageClassName string
AccessMode corev1.PersistentVolumeAccessMode
}
func NewStorageReconciler ¶
func NewStorageReconciler( storageConfig configapi.KaiwoStorageConfig, objectKey client.ObjectKey, accessMode corev1.PersistentVolumeAccessMode, storageClassName string, amount string, ) *StorageReconciler
func (*StorageReconciler) Build ¶
func (r *StorageReconciler) Build(ctx context.Context, _ client.Client) (*corev1.PersistentVolumeClaim, error)
func (*StorageReconciler) GetEmptyObject ¶
func (r *StorageReconciler) GetEmptyObject() *corev1.PersistentVolumeClaim
Click to show internal directories.
Click to hide internal directories.