<p>I have a service running on a Kubernetes cluster with many replications. My services are spring boot services.</p>
<p>I've no access to the DB, only the service does.</p>
<p>I need to run a script that alters schemas, it must be run once, and just before the newly deployed code starts running.</p>
<p>How can I run an SQL script exactly one time?</p>

hevi
<p>You can use <a href="https://kubernetes.io/docs/concepts/workloads/pods/init-containers/" rel="nofollow noreferrer">init container</a> for running a script. Init containers runs before the actual container runs.</p>
<p>Because init containers run to completion before any app containers start, init containers offer a mechanism to block or delay app container startup until a set of preconditions are met. Once preconditions are met, all of the app containers in a Pod can start in parallel.</p>
