<p>One of my namespace is in <code>Terminating</code> state.
While there are many posts that explain how to forcefully delete such namespaces. The ultimate result is that everything in your namespace will be gone. Which is not what you might want especially if that termination was a result of mistake or bug (or may cause downtime of any kind).</p>
<p>Is it possible to tell kubernetes not to try to delete that namespace anymore. Where that state is kept?</p>
<p><code>Terminating</code> state blocks me from recreating the whole stack with gitops (helm chart installation in such namespace is not possible).</p>
<p>I simply wish to remove the <code>terminating</code> state and my fluxcd controller would fix everything else.</p>

<blockquote>
<p>Is there a way to cancel namespace termination in kubernetes?</p>
</blockquote>
<p>As far as I know, unfortunately not. Termination is a one-way process. Note how <a href="https://unofficial-kubernetes.readthedocs.io/en/latest/concepts/abstractions/pod-termination/#:%7E:text=Kubernetes%20marks%20the%20Pod%20state,still%20running%20in%20the%20Pod." rel="nofollow noreferrer">termination pods take place</a>:</p>
<blockquote>
<ol>
<li>You send a command or API call to terminate the Pod.</li>
<li>Kubernetes updates the Pod status to reflect the time after which the Pod is to be considered &quot;dead&quot; (the time of the termination request plus the grace period).</li>
<li><strong>Kubernetes marks the Pod state as &quot;Terminating&quot; and stops sending traffic to the Pod.</strong></li>
<li><strong>Kubernetes send a  <code>TERM</code>  signal to the Pod, indicating that the Pod should shut dow</strong>n.</li>
<li><strong>When the grace period expires, Kubernetes issues a  <code>SIGKILL</code>  to any processes still running in the Pod.</strong></li>
<li>Kubernetes removes the Pod from the API server on the Kubernetes Master.</li>
</ol>
</blockquote>
<p>So it is impossible to cancel termination process.</p>
<blockquote>
<p>Is it possible to tell kubernetes not to try to delete that namespace anymore.</p>
</blockquote>
<p>There is no dedicated solution, but you can try to automate this process with custom scripts. Look at <a href="https://gist.github.com/jossef/a563f8651ec52ad03a243dec539b333d" rel="nofollow noreferrer">this example in Python</a> and another one <a href="https://stackoverflow.com/a/62463004/15407542">in Bash</a>.</p>
<p>See also <a href="https://stackoverflow.com/questions/52369247/namespace-stuck-as-terminating-how-i-removed-it">this question</a>.</p>
