<p>I have to write a deployment file for my application which takes run time commands and arguments at runtime.
e.g. <code>./foo bar -a=A -b=B</code>
This is my deployment file :</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: foo
spec:
  replicas: 1
  template:
    metadata:
      labels:
        name: foo
    spec:
      containers:
      - name: foo
        image: username/image:tag
        # command that to be executed at run time
        command: ["bar"]
        args:
        # This is the flag to pass at runtime
        - -a=A
        - -b=B
        ports:
        - containerPort: 9500
</code></pre>

<p>It says container command 'foo' not found or doesnot exist.
i'm passing a script as entrypoint and it has <code>exec  /usr/local/bin/foo</code> .
What's wrong with it ?</p>

<p>If you want start <code>./foo bar -a=A -b=B</code> in container, your deployment should contains</p>

<pre><code>- name: foo
  image: username/image:tag
  command: ["foo"]
  args: ["bar", "-a=A", "-b=B"]
</code></pre>

<p><a href="https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/</a></p>

<p>Be sure you have path to <strong>foo</strong> binary in your <strong>$PATH</strong> enviroment variable inside <code>username/image:tag</code> image (or use full path <code>/usr/local/bin/foo</code>).</p>

<p>You can check <code>$PATH</code> by </p>

<pre><code>kubectl run  test -ti --rm --image=username/image:tag --command -- echo $PATH

kubectl run  test -ti --rm --image=username/image:tag --command -- foo
</code></pre>
