@@ -375,7 +375,7 @@ done`, CABundleTempPath, CABundleSourceDir, fileList)
375375 },
376376 SecurityContext : & corev1.SecurityContext {
377377 AllowPrivilegeEscalation : ptr .To (false ),
378- RunAsNonRoot : ptr .To (false ),
378+ RunAsNonRoot : ptr .To (true ),
379379 Capabilities : & corev1.Capabilities {
380380 Drop : []corev1.Capability {"ALL" },
381381 },
@@ -390,7 +390,7 @@ func configurePodStorage(ctx context.Context, r *LlamaStackDistributionReconcile
390390 }
391391
392392 // Configure storage volumes and init containers
393- configureStorage (instance , & podSpec , container . Image )
393+ configureStorage (instance , & podSpec )
394394
395395 // Configure TLS CA bundle (with auto-detection support)
396396 configureTLSCABundle (ctx , r , instance , & podSpec , container .Image )
@@ -405,16 +405,16 @@ func configurePodStorage(ctx context.Context, r *LlamaStackDistributionReconcile
405405}
406406
407407// configureStorage handles storage volume configuration.
408- func configureStorage (instance * llamav1alpha1.LlamaStackDistribution , podSpec * corev1.PodSpec , image string ) {
408+ func configureStorage (instance * llamav1alpha1.LlamaStackDistribution , podSpec * corev1.PodSpec ) {
409409 if instance .Spec .Server .Storage != nil {
410- configurePersistentStorage (instance , podSpec , image )
410+ configurePersistentStorage (instance , podSpec )
411411 } else {
412412 configureEmptyDirStorage (podSpec )
413413 }
414414}
415415
416416// configurePersistentStorage sets up PVC-based storage with init container for permissions.
417- func configurePersistentStorage (instance * llamav1alpha1.LlamaStackDistribution , podSpec * corev1.PodSpec , image string ) {
417+ func configurePersistentStorage (instance * llamav1alpha1.LlamaStackDistribution , podSpec * corev1.PodSpec ) {
418418 // Use PVC for persistent storage
419419 podSpec .Volumes = append (podSpec .Volumes , corev1.Volume {
420420 Name : "lls-storage" ,
@@ -424,47 +424,6 @@ func configurePersistentStorage(instance *llamav1alpha1.LlamaStackDistribution,
424424 },
425425 },
426426 })
427-
428- // Add init container to fix permissions on the PVC mount.
429- mountPath := llamav1alpha1 .DefaultMountPath
430- if instance .Spec .Server .Storage .MountPath != "" {
431- mountPath = instance .Spec .Server .Storage .MountPath
432- }
433-
434- commands := []string {
435- fmt .Sprintf ("mkdir -p %s 2>&1 || echo 'Warning: Could not create directory'" , mountPath ),
436- fmt .Sprintf ("(chown 1001:0 %s 2>&1 || echo 'Warning: Could not change ownership')" , mountPath ),
437- fmt .Sprintf ("ls -la %s 2>&1" , mountPath ),
438- }
439- command := strings .Join (commands , " && " )
440-
441- initContainer := corev1.Container {
442- Name : "update-pvc-permissions" ,
443- Image : image ,
444- ImagePullPolicy : corev1 .PullAlways ,
445- Command : []string {
446- "/bin/sh" ,
447- "-c" ,
448- // Try to set permissions, but don't fail if we can't
449- command ,
450- },
451- VolumeMounts : []corev1.VolumeMount {
452- {
453- Name : "lls-storage" ,
454- MountPath : mountPath ,
455- },
456- },
457- SecurityContext : & corev1.SecurityContext {
458- RunAsUser : ptr .To (int64 (0 )), // Run as root to be able to change ownership
459- RunAsGroup : ptr .To (int64 (0 )),
460- AllowPrivilegeEscalation : ptr .To (false ),
461- Capabilities : & corev1.Capabilities {
462- Drop : []corev1.Capability {"ALL" },
463- },
464- },
465- }
466-
467- podSpec .InitContainers = append (podSpec .InitContainers , initContainer )
468427}
469428
470429// configureEmptyDirStorage sets up temporary storage using emptyDir.
@@ -620,8 +579,9 @@ func configurePodOverrides(instance *llamav1alpha1.LlamaStackDistribution, podSp
620579 }
621580
622581 // Set fsGroup to allow write access to mounted volumes
582+ const defaultFSGroup = 1001
623583 if podSpec .SecurityContext .FSGroup == nil {
624- podSpec .SecurityContext .FSGroup = ptr .To (int64 (0 ))
584+ podSpec .SecurityContext .FSGroup = ptr .To (int64 (defaultFSGroup ))
625585 }
626586
627587 // Apply other pod overrides if specified
0 commit comments