I have a 3rd party docker container which takes arguments of the form:
docker run foo --arg1 val1 --arg2 val2
and I have run it as a pod in kubernetes as follows:
spec:
containers:
- name: foo
image: foo
args:
- --arg1
- val1
- --arg2
- val2
This is good but I now need to have the two argument values dynamic. For example, val1 is the pod's name/id, and val2 is the zone (aws availability zone) of the node that the Pod is running on.
The only solution so I could think of is, to extend the container creating another image that runs a wrapper script, which queries for these two values and then pass them to the command line.
I am wondering if there's a more elegant solution than that. Let's say we can obtain these dynamic values in an initContainer. Now the question is how do we pass them on the command line of the main container.
PS: It looks like we can get the pod's name using Downward API. However, the Downward API does not expose node's label, for which there is an open issue. So, for this question, let's think our parameters are arbitrary and are obtained dynamically.