<p>I want the variable to be accessed by <code>gcr.io/******/serve_model:lat5</code> Image which is an argument of <code>gcr.io/******/deployservice:lat2</code></p>

<p>Initially I have tried passing the variable as argument but it didn't work, so I am trying to pass it as an environmental variable.<br>
My environmental variable will be an url of <code>GCP</code> storage bucket from where my <code>serve_model</code> will access the <code>.sav</code> model file.</p>

<pre><code>        name='web-ui',
        image='gcr.io/******/deployservice:lat2',
        arguments=[
        '--image', 'gcr.io/******/serve_model:lat5',
        '--name', 'web-ui',
        '--container-port', '8080',
        '--service-port', '80',
        '--service-type', "LoadBalancer"
        ]
        ).add_env_variable(V1EnvVar(name='modelurl', value=Model_Path))
</code></pre>

harish kumaar
<p><code>add_env_variable()</code> is a function of a <code>Container</code> object that's exposed as a property of a <code>ContainerOp</code>. </p>

<p>So something like below would work. Refer the kfp dsl code <a href="https://github.com/kubeflow/pipelines/blob/master/sdk/python/kfp/dsl/_container_op.py#L121" rel="nofollow noreferrer">here</a></p>

<pre><code>model_path = 'gcp://dummy-url'
container_op = ContainerOp(name='web-ui',
                               image='gcr.io/******/deployservice:lat2',
                               arguments=[
                                   '--image', 'gcr.io/******/serve_model:lat5',
                                   '--name', 'web-ui',
                                   '--container-port', '8080',
                                   '--service-port', '80',
                                   '--service-type', "LoadBalancer"]
                               )
container_op.container.add_env_variable(V1EnvVar(name='model_url', value=model_path))

</code></pre>

<p>You can verify this by checking the YAML in the zip for the <code>env</code> section under <code>-container</code></p>

<pre><code>  - container:
      args:
      - --image
      - gcr.io/******/serve_model:lat5
      - --name
      - web-ui
      - --container-port
      - '8080'
      - --service-port
      - '80'
      - --service-type
      - LoadBalancer
      env:
      - name: modelurl
        value: gcp://dummy-url &lt;--the static env value
      image: gcr.io/******/deployservice:lat2
</code></pre>
