<p>I have a configMap and I want to create a backup configMap by using the last applied configuration from that.</p>
<p>I use the following command to get the last applied configuration:</p>
<pre><code>    kubectl get cm app-map -n app-space \
    -o go-template \
    --template='{{index .metadata &quot;annotations&quot; &quot;kubectl.kubernetes.io/last-applied-configuration&quot;}}' &gt; backup.json
</code></pre>
<p>It returns something like this [the content of backup.json]:</p>
<pre><code>{&quot;kind&quot;:&quot;ConfigMap&quot;,&quot;apiVersion&quot;:&quot;v1&quot;,&quot;metadata&quot;:{&quot;name&quot;:&quot;app-map&quot;,&quot;creationTimestamp&quot;:null},&quot;data&quot;:{&quot;app.yml&quot;:&quot;xxxxxxxxx&quot;,&quot;config.yml&quot;:&quot;yyyyyyyyy&quot;}}
</code></pre>
<p>Now, I want my backup configMap to have a different name. So, I want to change the <code>.metadata.name</code> from <code>app-map</code> to <code>app-map-backup</code>.</p>
<p>Is there a way I can achieve that with <code>kubectl</code> and <code>-o go-template</code>? I want to have the name changed before I write it to the <code>backup.json</code> file.</p>
<p>I know I can do that using <code>jq</code> but I do not have permission to install <code>jq</code> on the server where I am using <code>kubectl</code>.</p>

bakadevops
<p>you could use <a href="https://github.com/emreodabas/kubectl-plugins#kubectl-bulk-aka-bulk-action" rel="nofollow noreferrer"><code>kubectl bulk</code></a> plugin. The below command will replicate your config map</p>
<pre><code># get resource(s) and create with field(name) change 
kubectl bulk configmap app-map -n app-space create name app-mapp-backup
</code></pre>
<p>Kubectl bulk is very powerful to use, I suggest to check <a href="https://github.com/emreodabas/kubectl-plugins#kubectl-bulk-aka-bulk-action" rel="nofollow noreferrer">samples</a>.</p>
