<p>I am trying to call <code>kubectl create -n $test_namespace -f &lt;absolute-path-to-tea-rc-file&gt;.yaml</code> from a shell script.</p>

<pre><code>#!/bin/bash

current_dir=$(pwd)
echo "current_dir is $current_dir"
parentdir="$(dirname "$current_dir")"
echo $parentdir
kubectl create -n $test_namespace -f $parentdir/deployment/common/tea-rc.yaml
</code></pre>

<p>It gives error as below:</p>

<pre><code>Bhagyashrees-MacBook-Pro:execution_controller bhagyashree$ sh test.sh 
current_dir is /Users/bhagyashree/Documents/FDrepo/armada-ingress-ctl-test/execution_controller
/Users/bhagyashree/Documents/FDrepo/armada-ingress-ctl-test
error: unknown command "/Users/bhagyashree/Documents/FDrepo/armada-ingress-ctl-test/deployment/common/tea-rc.yaml"
See 'kubectl create -h' for help and examples.
</code></pre>

<p>the same command works when it is executed from a terminal.
<code>kubectl create -n testnamespace -f /Users/bhagyashree/Documents/FDrepo/armada-ingress-ctl-test/deployment/common/tea-rc.yaml</code></p>

<p>What I am i missing here?</p>

<p>I think it's because the variable $test_namespace has not been set.</p>

<p>If you change the last line to <code>echo "kubectl create -n $test_namespace -f $parentdir/deployment/common/tea-rc.yaml"</code> you'll see what it's trying to run, it will look like <code>kubctl create -n  -f /path/to/dir/deployment/common/tea-rc.yaml</code>. The Namespace can not be left blank.</p>

<p>You could also try adding a line like <code>echo $test_namespace</code> to check.</p>
