<p>I am setting up the kubernetes setup for django webapp.</p>

<p>I am passing environment variable while creating deployment as below</p>

<pre><code>kubectl create -f deployment.yml -l key1=value1 
</code></pre>

<p>I am getting error as below</p>

<pre><code>error: no objects passed to create
</code></pre>

<p>Able to create the deployment successfully, If i remove the env variable -l key1=value1 while creating deployment.</p>

<p>deployment.yaml as below</p>

<pre><code>#Deployment
apiVersion: extensions/v1beta1
kind: Deployment
metadata: 
 labels: 
   service: sigma-service
 name: $key1
</code></pre>

<p>What will be the reason for causing the above error while creating deployment?</p>

rakeshh92
<p>I used envsubst (<a href="https://www.gnu.org/software/gettext/manual/html_node/envsubst-Invocation.html" rel="noreferrer">https://www.gnu.org/software/gettext/manual/html_node/envsubst-Invocation.html</a>) for this. Create a <code>deployment.yaml</code></p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: $NAME
  labels:
    app: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80
</code></pre>

<p>Then:</p>

<pre><code>export NAME=my-test-nginx
envsubst &lt; deployment.yaml | kubectl apply -f -
</code></pre>

<p>Not sure what OS are you using to run this. On macOS, envsubst installed like:</p>

<pre><code>brew install gettext
brew link --force gettext 
</code></pre>
