Skip to content

Commit 3a977c6

Browse files
Update PVC permissions for LLS (#111)
This commit fixes the write permissions for PVC ### Testing Updated permissions- <img width="1013" height="434" alt="Screenshot 2025-07-17 at 08 41 22" src="https://github.com/user-attachments/assets/be432482-2457-460b-b824-536479dbd73e" /> Approved-by: leseb
1 parent 728ed5f commit 3a977c6

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

controllers/resource_helper.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222

2323
llamav1alpha1 "github.com/llamastack/llama-stack-k8s-operator/api/v1alpha1"
2424
corev1 "k8s.io/api/core/v1"
25+
"k8s.io/utils/ptr"
2526
)
2627

2728
// buildContainerSpec creates the container specification.
@@ -109,6 +110,34 @@ func configurePodStorage(instance *llamav1alpha1.LlamaStackDistribution, contain
109110
},
110111
},
111112
})
113+
114+
// Add init container to fix permissions on the PVC mount
115+
mountPath := llamav1alpha1.DefaultMountPath
116+
if instance.Spec.Server.Storage.MountPath != "" {
117+
mountPath = instance.Spec.Server.Storage.MountPath
118+
}
119+
120+
initContainer := corev1.Container{
121+
Name: "update-pvc-permissions",
122+
Image: "registry.access.redhat.com/ubi9/ubi-minimal:latest",
123+
Command: []string{
124+
"/bin/sh",
125+
"-c",
126+
fmt.Sprintf("chown --verbose --recursive 1001:0 %s", mountPath),
127+
},
128+
VolumeMounts: []corev1.VolumeMount{
129+
{
130+
Name: "lls-storage",
131+
MountPath: mountPath,
132+
},
133+
},
134+
SecurityContext: &corev1.SecurityContext{
135+
RunAsUser: ptr.To(int64(0)), // Run as root to be able to change ownership
136+
RunAsGroup: ptr.To(int64(0)),
137+
},
138+
}
139+
140+
podSpec.InitContainers = append(podSpec.InitContainers, initContainer)
112141
} else {
113142
// Use emptyDir for non-persistent storage
114143
podSpec.Volumes = append(podSpec.Volumes, corev1.Volume{

0 commit comments

Comments
 (0)