<p>I want to setup my Django app in kubernetes environment in such a way that while creating the app container, environment variables are passed such that those environment variables are used to initiate the containers. For example on starting the app container I want to issue management commands such as</p>
<pre><code>python manage.py createuser --lastname lname --firstname --fname --number --num &quot;
</code></pre>
<p>and so on. How to pass these variable values such as lname and fname above inside the container in a generic way such that every time new values can be passed depending on the user credentials and they do not need to be hard coded everytime?</p>

<p>You can pass <a href="https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/#define-an-environment-variable-for-a-container" rel="nofollow noreferrer">environment variables</a> in your deployment manifest, for example:</p>
<pre><code>spec:
  containers:
  - name: envar-demo-container
    image: gcr.io/google-samples/node-hello:1.0
    env:
    - name: DEMO_GREETING
      value: &quot;Hello from the environment&quot;
    - name: DEMO_FAREWELL
      value: &quot;Such a sweet sorrow&quot;
</code></pre>
<p>You <a href="https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/#using-environment-variables-inside-of-your-config" rel="nofollow noreferrer">can also invoke them in container</a> by using <code>command</code> and <code>argument</code> object, the same way as running a command in container</p>
<pre><code>  containers:
  - name: env-print-demo
    image: bash
    env:
    - name: GREETING
      value: &quot;Warm greetings to&quot;
    - name: HONORIFIC
      value: &quot;The Most Honorable&quot;
    - name: NAME
      value: &quot;Kubernetes&quot;
    command: [&quot;echo&quot;]
    args: [&quot;$(GREETING) $(HONORIFIC) $(NAME)&quot;]
</code></pre>
<p>It is also possible to pass variables from <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#define-container-environment-variables-using-configmap-data" rel="nofollow noreferrer"><code>ConfigMap</code></a> or <a href="https://kubernetes.io/docs/tasks/inject-data-application/distribute-credentials-secure/#define-a-container-environment-variable-with-data-from-a-single-secret" rel="nofollow noreferrer"><code>Secrets</code></a>.</p>
