<p>Is there any command to revert back to previous configuration on a resource?</p>

<p>For example, if I have a Service kind resource created declaratively, and then I change the ports manually, how can I discard live changes so the original definition that created the resource is reapplied?</p>

<p>Is there any tracking on previous applied configs? it could be even nicer if we could say: reconfigure my service to current appied config - 2 versions.</p>

<p>EDIT: I know deployments have rollout options, but I am wondering about a Kind-wise mechanism</p>

Whimusical
<p>Since you're asking explicitly about the <code>last-applied-configuration</code> annotation...</p>
<p>Very simple:</p>
<pre><code>kubectl apply view-last-applied deployment/foobar-module | kubectl apply -f -
</code></pre>
<p>Given that <code>apply</code> composes via stdin ever so flexibly — there's no dedicated <code>kubectl apply revert-to-last-applied</code> subcommand, as it'd be redundant reimplementation of the simple pipe above.</p>
<p>One could also suspect, that such a <code>revert</code> built-in could never be made perfect, (as Nick_Kh notices) for complicated reasons. A subcommand named <code>revert</code> evokes a lot of expectation from users which it would never fulfill.</p>
<p>So we get a simplified approximation: a <code>spec.bak</code> saved in resource annotations, ready to be re-<code>apply</code>'d.</p>
