<p>I've created a <code>Makefile</code> to export a <code>kubeconfig</code> from <strong>fixed</strong> path like:</p>

<pre><code>myproj
 - .kube     //folder
     config    //file which contain the config
 - Makefile.  //same level as .kube folder
</code></pre>

<p>Now when I'm running <strong>from the terminal</strong> the following it works, I mean if I run <code>kubectl get ns</code> I got results which means that it configure <strong>successfully</strong>!</p>

<pre><code>export KUBECONFIG=/Users/i33333/projects/app-test/v-app/.kube/config
</code></pre>

<p>I've created a makefile target like following</p>

<pre><code>kube-cfg:
    export KUBECONFIG=$(PWD)/.kube/config
</code></pre>

<p>When execute the target I see in the terminal </p>

<pre><code>export KUBECONFIG=/Users/i33333/projects/app-test/v-app/.kube/config
</code></pre>

<p><strong>which exactly the same</strong> as doing that manually but when when I run <code>kubectl get ns</code></p>

<p>I got error: </p>

<pre><code>error: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
</code></pre>

<p>I dont understand why it <strong>dosent work when I run it from makefile</strong>  and works when I run it from the terminal manually ? any idea 
I try to change and use also the $(CURRDIR) which doesnt help</p>

<p><strong>update</strong></p>

<p>I've tried like suggested which doesnt works</p>

<pre><code>KUBECONFIG=$(PWD)/.kube/config


kube-cfg:
    export $(KUBECONFIG)
</code></pre>

<p><strong>update2</strong></p>

<p>If I do it like this</p>

<pre><code>KUBECONFIG := $(PWD)/kube/config.yaml
tgt1:
    @export KUBECONFIG=$(KUBECONFIG) &amp;&amp; kubectl get ns
</code></pre>

<p><strong>I was able to see the ns</strong> when running the makefile <code>tgt1:</code> but 
if now I want to run it from the terminal <code>kubectl get ns</code> I get the same error `error: no configuration has been provided, try setting KUBERNETES_MASTER environment variable, <strong>I want to configure it from the makefile</strong></p>

<p>The problem is that makefile recipe creates new environment, which is destroyed after finishing recipe.</p>

<p>If you want to use kubernetes tools after calling make, more appropriate tool in your scenario is using <code>source</code> command. It applies in your current environment all changes made in script passed as parameter:</p>

<pre><code>$ source setupenv.sh
$ kubectl get ns # should be no problem
$ make someting # even using kubectl inside make shouldn't be a problem
</code></pre>

<p>However if you want to use kubectl in make scripts, then create something like:</p>

<pre><code>recipe :
      source setupenv.sh &amp;&amp; kubectl get ns
# or 
recipe2 :
      export KUBECONFIG=$(PWD)/.kube/config &amp;&amp; kubectl get ns
</code></pre>

<p><b>UPDATE</b>:</p>

<p>I thought config file is a script. So you should prepare shell script setting up environment, for example <code>setupenv.sh</code>:</p>

<pre><code>#!/bin/bash
export KUBECONFIG=$(PWD)/.kube/config
</code></pre>
