<p>We have a number of pods communicating with each other and storing state via either etc or shared PVs.  Sometimes we get in a messed up state and we want to have a command that will blow away all our saved state and restart things fresh as a debug tool.</p>
<p>To do this we need to stop a number of containers, across many nodes.  Once stopped we need to delete data in ETC and volumes, then once that's done restart the containers.</p>
<p>This seems pretty easy to do with a bash script, but my management doesn't want a bash script since we only deploy kubernetes configuration and he doesn't want a separate script to exist but not be deployed automatically with the rest of our codebase.</p>
<p>I'm wondering if I can use something similar to kubernetes jobs, or any other tool, to set up the same logic within kubernetes so it's deployed with the rest of our kubernetes code. Something where I can run a simple command and have my prewritten scripted logic run to completion?  I had hoped a kubernetes job would work, but the job wouldn't have access to kubectl or any way of starting and stopping other pods or containers.</p>
<p>Is there a kubernetes functionality I missed to make it easier to pause multiple pods while our cleanup logic runs?</p>

dsollen
<p>Ansible can be used for running commands in your nodes, you can use ansible playbooks instead of bash script or you can use this playbook to run your bash script. Similarly there are tools like rundeck and n8n if you prefer a webhook method of implementation. If you are planning to implement a CICD pipeline you can use tools like Jenkins.</p>
