<p>In dag script</p>
<pre><code>PARAM = {
    'key1' : 'value1',
    'key2' : 'value2'
}

t1 = KubernetesPodOperator(
    task_id=task_id,
    name=task_name,
    cmds=[&quot;pipenv&quot;, &quot;run&quot;, &quot;python3&quot;, &quot;myscript.py&quot;],
    env_vars={
        'GCS_PROJECT': GCS_PROJECT,
        'GCS_BUCKET': GCS_BUCKET,
        'PARAM': PARAM # this line throws an error
    },
    image=docker_image
)
</code></pre>
<p>I failed to pass a dictionary (PARAM) in the case above. I tried to pass two lists (a list of keys and a list of values so that I can zip them later) but it didn't work too. The error message is something like this</p>
<pre><code>kubernetes.client.exceptions.ApiException: (400)
Reason: Bad Request
HTTP response headers: ......
HTTP response body: {
    ......    
    &quot;apiVersion&quot;:&quot;v1&quot;,
    &quot;metadata&quot;:{},
    &quot;status&quot;:&quot;Failure&quot;,
    &quot;message&quot;:&quot;Pod in version \&quot;v1\&quot; cannot be handled as a Pod: json: cannot be unmarshal object into Go struct field EnvVar.spec.containers.env.value of type string&quot;
    ....
}
</code></pre>
<p>Is there a way in which I can pass PARAM?</p>

zZzZ
<p>Environment variables are <em>strings</em>. You cannot pass a structured variable like a dictionary in an environment variable unless you first convert it into a string (e.g, by serializing it to JSON). You could do this:</p>
<pre><code>t1 = KubernetesPodOperator(
    task_id=task_id,
    name=task_name,
    cmds=[&quot;pipenv&quot;, &quot;run&quot;, &quot;python3&quot;, &quot;myscript.py&quot;],
    env_vars={
        'GCS_PROJECT': GCS_PROJECT,
        'GCS_BUCKET': GCS_BUCKET,
        'PARAM': json.dumps(PARAM),
    },
    image=docker_image,
)
</code></pre>
