<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jacob Tomlinson</title>
    <description>The latest articles on DEV Community by Jacob Tomlinson (@jacobtomlinson).</description>
    <link>https://dev.to/jacobtomlinson</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F264807%2F8568d77a-9908-4182-b879-41de7972b844.jpeg</url>
      <title>DEV Community: Jacob Tomlinson</title>
      <link>https://dev.to/jacobtomlinson</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jacobtomlinson"/>
    <language>en</language>
    <item>
      <title>How to merge Kubernetes kubectl config files</title>
      <dc:creator>Jacob Tomlinson</dc:creator>
      <pubDate>Mon, 09 Dec 2019 14:09:10 +0000</pubDate>
      <link>https://dev.to/jacobtomlinson/how-to-merge-kubernetes-kubectl-config-files-50fp</link>
      <guid>https://dev.to/jacobtomlinson/how-to-merge-kubernetes-kubectl-config-files-50fp</guid>
      <description>&lt;p&gt;Sometimes when working with a new Kubernetes cluster you will be given a config file to use when authenticating with the cluster. This file should be placed at &lt;code&gt;~/.kube/config&lt;/code&gt;. However you may already have an existing config file at that location and you need to merge them together.&lt;/p&gt;

&lt;p&gt;Here is a quick command you can run to merge your two config files.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;Make a copy of your existing config
&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;cp&lt;/span&gt; ~/.kube/config ~/.kube/config.bak
&lt;span class="go"&gt;
&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;Merge the two config files together into a new config file
&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;KUBECONFIG&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;~/.kube/config:/path/to/new/config kubectl config view &lt;span class="nt"&gt;--flatten&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /tmp/config
&lt;span class="go"&gt;
&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;Replace your old config with the new merged config
&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;mv&lt;/span&gt; /tmp/config ~/.kube/config
&lt;span class="go"&gt;
&lt;/span&gt;&lt;span class="gp"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;optional&lt;span class="o"&gt;)&lt;/span&gt; Delete the backup once you confirm everything worked ok
&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;rm&lt;/span&gt; ~/.kube/config.bak
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here is all of that (except the cleanup) as a one-liner.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;cp&lt;/span&gt; ~/.kube/config ~/.kube/config.bak &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nv"&gt;KUBECONFIG&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;~/.kube/config:/path/to/new/config kubectl config view &lt;span class="nt"&gt;--flatten&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /tmp/config &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;mv&lt;/span&gt; /tmp/config ~/.kube/config
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>kubernetes</category>
      <category>cli</category>
      <category>tips</category>
    </item>
  </channel>
</rss>
