last day (19 days later) » 

9:18 AM
2
A: Kubernetes mounted volume has root ownership

akopYou didn't mention your k8s version. My answer might not be suitable for you, when you're using k8s below of v1.23. Kubernetes can setup the permissions for you. Use fsGroup and fsGroupChangePolicy and k8s will take over the job for you. containers: - name: laravel-api-app image: me/laravel...

 
I'll try it, I am running MicroK8s v1.25.6 revision 4565
I tried your solution, but I am still getting an Init:ExitCode:127. I also tried placing that securityContext one level bove, so on the same level as containers, but that didn't work either? My init container is crashing, so lets focus on that first. Is my copy command correct?
 
You don't need the init-container anymore.
 
I do right? If I mount the storage pv it is empty on first run, and I need to copy the folder structure that is already in there right?
Well besided that, the mounted volume still isn't configured correctly, because I am seeing these 2 lines in the log: cp: can't create directory '/mnt/app': Permission denied and cp: can't create directory '/mnt/framework': Permission denied
 
/mnt/app/ is not the path of your mount. :P
 
Yes it is, look at the initContainer. I am mounting that volume to /mnt and then copy everything from /var/www/html/storage to that /mnt. The folders inside /var/www/html/storage are: app, framework and logs. After the init is completed I mount that volume as /var/www/html/storage for the actual container. Or maybe I am seeing something wrong, could also be the case :)
 
9:18 AM
Ah sorry, my bad. I overlooked that you had two init-containers. You need the security-group then also at your initContainer.
 
I already did add it to the init container :(
 
Can you add your current yamls to the question? ^^
 
I already did add it to the init container... The weird thing is that when I look at the live manifest, I see this: securityContext: {}. This should be filled then with your code
I have added my new yaml to the question, as well as the live manifest ArgoCD uses
 
Are you sure, that you applied the correct yaml? Seems very weird to me, that the context will be dropped.
 
9:37 AM
Yeah, I will check in a sec when I am back behind my 💻. I'll keep you in touch
Every change I did after adding securitycontext, does get applied, so it is weird it the securitycontext doesn't get applied
 
10:30 AM
The weird thing is that it keeps saying OutOfSync on my laravel-api deployment. The SecurityContext stays empty but other changes do get applied, so it looks like the deployment doesn't like the SecurityContext for some reason?
When I move the SecurityContext out of my container and place it on the same level as my volumes, it does get deployed succesfully, but then I still get the permission denied
 

  last day (19 days later) »