<p>I'm trying to export some kube resources (configmaps, deployments, services)  from one cluster so that it can be applied to another.</p>

<p>Something like this ....</p>

<p>kubectl --kubeconfig ${src} -n ${ns} get configmaps ${cm} -o yaml | \
   kubectl --kubeconfig ${dst} -n ${ns} apply -f -</p>

<p>It kind works, once.  The first time where the resource hasn't been created yet.   If I run it a second time, trying to update the destination I get error like...</p>

<p><strong>the object has been modified; please apply your changes to the latest version and try again.</strong></p>

<p>I suspect it has something to do with the resourceVersion or timestamp fields that appear in the output.</p>

<p>Is there away to output a resource so that is striped of all server side specific info?  Other that a bunch of sed delete and grep -v statements.</p>

<p>TIA</p>

<p>You can use below command with <code>--export</code> flag to strip of cluster-specific information.</p>

<pre><code>kubectl get cm cmname -o yaml --export &gt; cm.yaml
</code></pre>

<p>A word of caution that <code>--export</code> is deprecated and going to be removed in future. So use it at your own risk.</p>
