If you are not principal expert in kubernetes, someday you may find yourself struggled with question «how i can restart my pods regularly?».
This question may look very strange. And partially it is.
But before you close this article, i try to justify this need.
Very often in our backend developer careers we write not so good code. It may look good, been validated via static analysis, covered with tests, covered with mutation tests, fuzzy tests, and also you team may consist of thousands of QA's and you have much more safety nets around. And all this things are failed miserably against one little bug, that can be reproduced in any environment no matter how hard you try. And it could be worse - this bug can only be reproduced after a certain period of time. This is nightmare of every software engineer.
But production services won't wait for your detective efforts. They simply can't wait unpredictable period of time.
And, here we are — staring at the weapon of last resort. Yep, this is shameful choice: you should restart you service on regular basis. And yes, this «solution» will easily fix this impudent irreproducible bug.
If you try to search possible ways of doing so in k8s cluster, you may find about 5 possible ways. And i personally choose only one of them. It also may look strange, but it's the easiest way: just use scheduled CI jobs (if you are using gitlab, for example) and run command
kubectl restart in this scheduled job.
This is the easiest, fastest and bug free path.