-
-
Notifications
You must be signed in to change notification settings - Fork 302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Daily Reboot Cronjob (K8s) #206
Conversation
Requires the k8s deployment to be in the palworld namespace. 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. 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. :)
Removed commented out section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 it
Really, 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reviewed it but as @Twinki14 said, this would fit in the helm chart too. Can you add that?
If you add a kustomization.yaml you could easily patch every namespace as well as the SA reference in the role binding :)
k8s/cronjob-reboot/cronjob.yaml
Outdated
command: | ||
- /bin/sh | ||
- -c | ||
- /restart-script/restart-deployment.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you even need a CM with the shell script? what about inline?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a good point, I'm not sure actually. Pardon my ignorance, I'm a little new to this - when you say inline, do you mean taking the contents of the shell script and making it a one-liner instead of using a CM and mounting it as a volume?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi sorry for the confusion. What i mean is instead of having a configmap mounted you could also put that script in that command as an arg like
command:
- /bin/sh
- -c
args:
- |
cont=$(kubectl -n palworld get pods -o=jsonpath='{.items[?(@.metadata.labels.app=="palworld-server")].metadata.name}')
kubectl exec -n palworld -i pod/$cont rcon-cli "Broadcast Saving_Server_Data..."
kubectl exec -n palworld -i pod/$cont rcon-cli save
sleep 30
kubectl exec -n palworld -i pod/$cont rcon-cli "Broadcast Backing_up_Server_Data..."
kubectl exec -n palworld -i pod/$cont backup
...
Indentation; namespace adjustment
Remove namespace
Remove namespace
Remove namespace
Remove namespace
Add additional parameters for cronjob
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 |
Implemented loop by @PaulusParssinen
Forgot escape characters.
@NotaSF Is this ready to merge? |
Add suggestion for cronjob CM script cleanup Co-authored-by: Paulus Pärssinen <[email protected]>
…boot/rolebinding.yaml
…-reboot/serviceaccount.yaml
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 |
Generated updated VALUES_SUMMARY with helm-docs
Fix markdown linting error
Found the source of the markdown lint failure - should be good now. |
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
Choices
Test instructions
kubectl -n palworld logs job/jobnamehere
Checklist before requesting a review