Closed Divinii closed 5 months ago
Hey thanks for this! Admittedly I have not tested this on my own cluster since I made that change. I was just trying to help folks running outside of Kubernetes that think they need to have access to the files locally and keep doing bind mounts. I'll enhance the check and make your recommended change regarding the security context. Cheers.
Would not the recreate potentially cause a loss of data?
Well the difference is that with the behavious as is it creates a second Pod on updates/redeploys, this pod tries to mount the PV and then fails if the PV is RWO. Recreate Terminates the Pod gracefully, after it is fully terminated it creates the new Pod. It does not cause a loss of data. I would be more concerned with a loss of data with the behaviour as is, because on a redeploy two servers try to access the same savegame at the same time. (depending on how fast the server process actually starts) In my case it took a few minutes to start the server fully.
Ok - that makes sense to me. I will make the necessary change.
Using a StatefulSet
might be a good alternative as well, since they are designed to handle the PVC and Recreation
That's actually not a bad idea, I didn't think about doing a stateful set. I'll play around with this.
For the issue mentioned above with fs groups, I changed the entrypoint to have this:
# Check for proper save permissions
if ! touch "${ENSHROUDED_PATH}/savegame/test"; then
echo ""
echo "ERROR: The ownership of /home/steam/enshrouded/savegame is not correct and the server will not be able to save..."
echo "The directory that you are mounting into the container needs to be owned by 'steam' (uid 10000)"
echo "from your container host attempt the following command 'chown -R 10000:10000 /your/enshrouded/folder'"
echo ""
exit 1
fi
rm "${ENSHROUDED_PATH}/savegame/test"
This has been fixed in image v2.0.2
The current deployment in Kubernetes does not work properly for me because of various reasons:
fsgroup is not set to 10000
When obtaining storage from Kubernetes while running a specific userid other than root you want to tell Kubernetes to handle the Permissions for you with fsgroup:
Filesystem permission check only checks the folder permissions of the Persistent Mountpoint
In my case the Mountpoint is owned by root but I set fsgroup to 10000 which results in the Permissions in the Volume to be 10000 when you create files. I think the permissions check could be improved by checking if a file inside /home/steam/enshrouded/savegame/ can be created.
![image](https://github.com/jsknnr/enshrouded-server/assets/37466196/1e6453d8-3ac3-47fe-b9ea-81ddc0d850fc)
Set scaling and upgrade policy to recreate
When a Volume in Kubernetes is RWO (ReadWriteOnce) you cannot redeploy the workload because the pv cannot be attached to the newly created pod.
I hope this helps, if you need me to test anything on kubernetes for you hit me up!