Repository: vllm-project/aibrix
File: api/orchestration/v1alpha1/kvcache_types.go (Go)

Code before:
	// +kubebuilder:validation:Optional
	// +kubebuilder:default:="IfNotPresent"
	ImagePullPolicy string `json:"imagePullPolicy,omitempty"`

	// shared memory size for kvcach
	// +kubebuilder:validation:Optional
	// +kubebuilder:default:=""
	SharedMemorySize string `json:"sharedMemorySize,omitempty"`

	// kvcache environment configuration
	// +kubebuilder:validation:Optional
	// +kubebuilder:default:={}
	Env []corev1.EnvVar `json:"env,omitempty"`

	// the memory resources of kvcache container
	// +kubebuilder:validation:Optional
	// +kubebuilder:default:="2Gi"
	Memory string `json:"memory,omitempty"`

	// the cpu resources of kvcache container
	// +kubebuilder:validation:Optional
	// +kubebuilder:default:="1"
	CPU string `json:"cpu,omitempty"`
}

type AffinityConfig struct {
	// NodeAffinity specifies node affinity scheduling rules for the pod
	// +kubebuilder:validation:Optional
	NodeAffinity *corev1.NodeAffinity `json:"nodeAffinity,omitempty"`

	// PodAffinity specifies pod affinity scheduling rules
	// +kubebuilder:validation:Optional
	PodAffinity *corev1.PodAffinity `json:"podAffinity,omitempty"`

	// PodAntiAffinity specifies pod anti-affinity scheduling rules
	// +kubebuilder:validation:Optional
	PodAntiAffinity *corev1.PodAntiAffinity `json:"podAntiAffinity,omitempty"`

	// EnableDefaultAntiAffinity will create default anti-affinity rules between KVCache pods
	// to distribute them across different nodes when true
	// +kubebuilder:validation:Optional
	// +kubebuilder:default:=true
	EnableDefaultAntiAffinity bool `json:"enableDefaultAntiAffinity,omitempty"`
}

// KVCacheSpec defines the desired state of KVCache
type KVCacheSpec struct {
	// Replicas is the number of kv cache pods to deploy
	// +kubebuilder:validation:Required
	// +kubebuilder:default:=1
	Replicas int32 `json:"replicas,omitempty"`

Review comment (suggestion):
we can use annotation to control it for short term, we can have an `v1alpha2` version for spec change later. seems your changes below doesn't leverage this yet.

Code after:
	// +kubebuilder:validation:Optional
	// +kubebuilder:default:="IfNotPresent"
	ImagePullPolicy string `json:"imagePullPolicy,omitempty"`

	// shared memory size for kvcach
	// +kubebuilder:validation:Optional
	// +kubebuilder:default:=""
	SharedMemorySize string `json:"sharedMemorySize,omitempty"`

	// kvcache environment configuration
	// +kubebuilder:validation:Optional
	// +kubebuilder:default:={}
	Env []corev1.EnvVar `json:"env,omitempty"`

	// the memory resources of kvcache container
	// +kubebuilder:validation:Optional
	// +kubebuilder:default:="2Gi"
	Memory string `json:"memory,omitempty"`

	// the cpu resources of kvcache container
	// +kubebuilder:validation:Optional
	// +kubebuilder:default:="1"
	CPU string `json:"cpu,omitempty"`
}

// KVCacheSpec defines the desired state of KVCache
type KVCacheSpec struct {
	// Replicas is the number of kv cache pods to deploy
	// +kubebuilder:validation:Required
	// +kubebuilder:default:=1
	Replicas int32 `json:"replicas,omitempty"`

	// EtcdReplicas describe the etcd replicas
	// +kubebuilder:validation:Optional
	// +kubebuilder:default:=1
	EtcdReplicas int32 `json:"etcdReplicas,omitempty"`

	// Metadata configuration for kv cache service
	// +kubebuilder:validation:Optional
	// +kubebuilder:default:={etcd: {image: "", replicas: 1, storage: {size: "10Gi"}}}
	Metadata MetadataConfig `json:"metadata,omitempty"`

	// kvcache dataplane container configuration
	// +kubebuilder:validation:Optional
	//nolint: lll
	// +kubebuilder:default:={image: "aibrix/kvcache:20241120", imagePullPolicy: "IfNotPresent"}
	Cache CacheSpec `json:"cacheSpec,omitempty"`

	// cache's service
	// +kubebuilder:validation:Optional
	// +kubebuilder:default:={type: "ClusterIP", port: 9600}