@@ -50,6 +50,8 @@ type VLLMRuntimeReconciler struct {
5050// +kubebuilder:rbac:groups=core,resources=configmaps,verbs=get;list;watch;create;update;patch;delete
5151// +kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch;create;update;patch;delete
5252// +kubebuilder:rbac:groups=core,resources=services,verbs=get;list;watch;create;update;patch;delete
53+ // +kubebuilder:rbac:groups=core,resources=persistentvolumeclaims,verbs=get;list;watch;create;update;patch;delete
54+ // +kubebuilder:rbac:groups=core,resources=persistentvolumes,verbs=get;list;watch;create;update;patch;delete
5355
5456// Reconcile is part of the main kubernetes reconciliation loop which aims to
5557// move the current state of the cluster closer to the desired state.
@@ -105,6 +107,40 @@ func (r *VLLMRuntimeReconciler) Reconcile(ctx context.Context, req ctrl.Request)
105107 return ctrl.Result {Requeue : true }, nil
106108 }
107109
110+ // Check if the pv already exists, if not create a new one
111+ foundPV := & corev1.PersistentVolume {}
112+ err = r .Get (ctx , types.NamespacedName {Name : "shared-pvc-storage" , Namespace : vllmRuntime .Namespace }, foundPV )
113+ if err != nil && errors .IsNotFound (err ) {
114+ // Define a new pv
115+ pv := r .pvForVLLMRuntime (vllmRuntime )
116+ log .Info ("Creating a new PV" , "PV.Namespace" , pv .Namespace , "PV.Name" , pv .Name )
117+ err = r .Create (ctx , pv )
118+ if err != nil {
119+ log .Error (err , "Failed to create new PV" , "PV.Namespace" , pv .Namespace , "PV.Name" , pv .Name )
120+ return ctrl.Result {}, err
121+ }
122+ } else if err != nil {
123+ log .Error (err , "Failed to get PV" )
124+ return ctrl.Result {}, err
125+ }
126+
127+ // Check if the pvc already exists, if not create a new one
128+ foundPVC := & corev1.PersistentVolumeClaim {}
129+ err = r .Get (ctx , types.NamespacedName {Name : "shared-pvc-storage-claim" , Namespace : vllmRuntime .Namespace }, foundPVC )
130+ if err != nil && errors .IsNotFound (err ) {
131+ // Define a new pvc
132+ pvc := r .pvcForVLLMRuntime (vllmRuntime )
133+ log .Info ("Creating a new PVC" , "PVC.Namespace" , pvc .Namespace , "PVC.Name" , pvc .Name )
134+ err = r .Create (ctx , pvc )
135+ if err != nil {
136+ log .Error (err , "Failed to create new PVC" , "PVC.Namespace" , pvc .Namespace , "PVC.Name" , pvc .Name )
137+ return ctrl.Result {}, err
138+ }
139+ } else if err != nil {
140+ log .Error (err , "Failed to get PVC" )
141+ return ctrl.Result {}, err
142+ }
143+
108144 // Check if the deployment already exists, if not create a new one
109145 found := & appsv1.Deployment {}
110146 err = r .Get (ctx , types.NamespacedName {Name : vllmRuntime .Name , Namespace : vllmRuntime .Namespace }, found )
@@ -148,10 +184,48 @@ func (r *VLLMRuntimeReconciler) Reconcile(ctx context.Context, req ctrl.Request)
148184 return ctrl.Result {}, nil
149185}
150186
187+ func (r * VLLMRuntimeReconciler ) pvForVLLMRuntime (vllmRuntime * productionstackv1alpha1.VLLMRuntime ) * corev1.PersistentVolume {
188+ return & corev1.PersistentVolume {
189+ ObjectMeta : metav1.ObjectMeta {
190+ Name : "shared-pvc-storage" ,
191+ Namespace : vllmRuntime .Namespace ,
192+ Labels : map [string ]string {"app" : vllmRuntime .Name },
193+ },
194+ Spec : corev1.PersistentVolumeSpec {
195+ AccessModes : []corev1.PersistentVolumeAccessMode {corev1 .ReadWriteMany },
196+ StorageClassName : "" ,
197+ Capacity : corev1.ResourceList {corev1 .ResourceStorage : resource .MustParse ("100Gi" )},
198+ PersistentVolumeSource : corev1.PersistentVolumeSource {
199+ HostPath : & corev1.HostPathVolumeSource {
200+ Path : "/data/shared-pvc-storage" ,
201+ },
202+ },
203+ },
204+ }
205+ }
206+
207+ func (r * VLLMRuntimeReconciler ) pvcForVLLMRuntime (vllmRuntime * productionstackv1alpha1.VLLMRuntime ) * corev1.PersistentVolumeClaim {
208+ return & corev1.PersistentVolumeClaim {
209+ ObjectMeta : metav1.ObjectMeta {
210+ Name : "shared-pvc-storage-claim" ,
211+ Namespace : vllmRuntime .Namespace ,
212+ Labels : map [string ]string {"app" : vllmRuntime .Name },
213+ },
214+ Spec : corev1.PersistentVolumeClaimSpec {
215+ AccessModes : []corev1.PersistentVolumeAccessMode {corev1 .ReadWriteMany },
216+ StorageClassName : & []string {"" }[0 ],
217+ Resources : corev1.VolumeResourceRequirements {
218+ Requests : corev1.ResourceList {corev1 .ResourceStorage : resource .MustParse ("100Gi" )},
219+ },
220+ },
221+ }
222+ }
223+
151224// deploymentForVLLMRuntime returns a VLLMRuntime Deployment object
152225func (r * VLLMRuntimeReconciler ) deploymentForVLLMRuntime (vllmRuntime * productionstackv1alpha1.VLLMRuntime ) * appsv1.Deployment {
153- labels := map [string ]string {
154- "app" : vllmRuntime .Name ,
226+ labels := map [string ]string {"app" : vllmRuntime .Name }
227+ for k , v := range vllmRuntime .Labels {
228+ labels [k ] = v
155229 }
156230
157231 // Define probes
@@ -178,7 +252,7 @@ func (r *VLLMRuntimeReconciler) deploymentForVLLMRuntime(vllmRuntime *production
178252 Scheme : corev1 .URISchemeHTTP ,
179253 },
180254 },
181- InitialDelaySeconds : 240 ,
255+ InitialDelaySeconds : 500 ,
182256 PeriodSeconds : 10 ,
183257 TimeoutSeconds : 3 ,
184258 SuccessThreshold : 1 ,
@@ -260,6 +334,15 @@ func (r *VLLMRuntimeReconciler) deploymentForVLLMRuntime(vllmRuntime *production
260334 })
261335 }
262336
337+ if vllmRuntime .Spec .Model .EnableLoRA {
338+ env = append (env ,
339+ corev1.EnvVar {
340+ Name : "VLLM_ALLOW_RUNTIME_LORA_UPDATING" ,
341+ Value : "True" ,
342+ },
343+ )
344+ }
345+
263346 // LM Cache configuration
264347 if vllmRuntime .Spec .LMCacheConfig .Enabled {
265348 env = append (env ,
@@ -424,6 +507,22 @@ func (r *VLLMRuntimeReconciler) deploymentForVLLMRuntime(vllmRuntime *production
424507 Resources : resources ,
425508 ReadinessProbe : readinessProbe ,
426509 LivenessProbe : livenessProbe ,
510+ VolumeMounts : []corev1.VolumeMount {
511+ {
512+ Name : "shared-pvc-storage" ,
513+ MountPath : "/data/shared-pvc-storage" ,
514+ },
515+ },
516+ },
517+ },
518+ Volumes : []corev1.Volume {
519+ {
520+ Name : "shared-pvc-storage" ,
521+ VolumeSource : corev1.VolumeSource {
522+ PersistentVolumeClaim : & corev1.PersistentVolumeClaimVolumeSource {
523+ ClaimName : "shared-pvc-storage-claim" ,
524+ },
525+ },
427526 },
428527 },
429528 },
0 commit comments