palworld-server-docker
palworld-server-docker copied to clipboard
Add Daily Reboot Cronjob (K8s)
Requires the k8s deployment to be in the palworld namespace.
Currently, it is set to run at 9:30am UTC daily.
I'm newer to configuring such things, and will work to improve/cleanup a little bit. :)
Context
- This launches a cronjob to run a shell script (defined in cm.yaml), which sends a broadcast notifying players that the server is saving. After 30 seconds, it does a formal backup using the established 'exec pod/podnamehere backup' command in the repo. After 30 seconds later, it sends a broadcast notifying players that the server will reboot in 60 seconds; 30 seconds; then each second for the last 10 seconds. It the runs the "Shutdown 1" command via rcon-cli, waits 30 additional seconds, then redeploys the application.
Choices
- I prefer the K8s cluster schedule and perform a cronjob so I can keep track of it and also rollback if needed.
- This made the most sense to me, as it does not intrude or alter the main image itself.
- I wanted to learn more about how CronJobs work in Kubernetes.
Test instructions
- Copy the folder and its contents
- Edit the cronjob.yaml schedule to '* * * * *' so it schedules it immediately.
- Log into server
- Apply the yaml files, specifically applying cronjob.yaml last.
- Wait for the broadcasts, also monitor the logs of the job created using
kubectl -n palworld logs job/jobnamehere - Server should disconnect once timer reaches 0; redeployment should be under way.
- Server should come back up once redeployment is finished.
Checklist before requesting a review
- [x] I have performed a self-review of my code
- [x] I've added documentation about this change to the README.
- [x] I've not introduced breaking changes.
I would say,
- Add this to the helm chart, and make it opt-in, it's far better suited for the helm chart
- If we still want this in the repository (outside the helm chart), let's store it only as an example, perhaps in a directory
k8s/examples/daily-restart, with an included readme to explain it and note any requirements/changes someone would need to make to use itReally, since we have a helm chart now, we don't need to have the raw k8s manifests like we do now anyway. Helm is extremely simple to setup in a k8s environment, and is basically the defacto standard in any k8s environment
I have made some changes and added helm chart values. Tested on my dev cluster... let me know if some additional changes would be needed.
I have made some changes and added helm chart values. Tested on my dev cluster... let me know if some additional changes would be needed.
Nice 👍 My only final nit-pick is the config map script, I think that can definitely be cleaned up with some type of for-loop
@NotaSF Is this ready to merge?
Did some last minute cleanup, moving it to an examples folder instead.
It should be ready for merge, but I must admit I do not know how to update the chart metadata with the newly-added chart values other than manually adding them.
EDIT - Found it, my bad. VALUES_SUMMARY has been updated; entire PR is ready to merge. @thijsvanloef
Found the source of the markdown lint failure - should be good now.