I have to write a deployment file for my application which takes run time commands and arguments at runtime. e.g. ./foo bar -a=A -b=B This is my deployment file :
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: 9500It says container command 'foo' not found or doesnot exist. i'm passing a script as entrypoint and it has exec /usr/local/bin/foo . What's wrong with it ?
If you want start ./foo bar -a=A -b=B in container, your deployment should contains
- name: foo
image: username/image:tag
command: ["foo"]
args: ["bar", "-a=A", "-b=B"]https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/
Be sure you have path to foo binary in your $PATH enviroment variable inside username/image:tag image (or use full path /usr/local/bin/foo).
You can check $PATH by
kubectl run test -ti --rm --image=username/image:tag --command -- echo $PATH
kubectl run test -ti --rm --image=username/image:tag --command -- foo