-
Notifications
You must be signed in to change notification settings - Fork 842
Support for more variables and variable expansion in app definition #1828
Comments
Thanks for the feature request, I'm adding it to our backlog. |
+1 |
Hi @F21, thanks for your input! Please try to be as specific as possible, look for duplicates and try to break up potentially unrelated things into multiple issues. "Support for more variables such as $ip" -- You mean along the lines of https://mesosphere.github.io/marathon/docs/task-environment-vars.html? So probably better call them "$MARATHON_IP" or something similar? How should these variables be defined? Please note that Marathon has to be able to calculate these variables when passing the "Ability to have these variables expanded in the app's definition." -- Do you mean that Marathon should expand them? Marathon can only expand them if it knows the values of the referenced variables when it launches the task. Thus it can only possibly substitute other variables passed in the For backward compatibility, we also might want to only substitute variables if another configuration option is set or a global configuration option of Marathon is set. Otherwise old AppDefinitions might start to behave differently. (This seems to be related to #1401) |
I can think of at least one i really wish marathon had: counter variables! :) I.e. Pass in something like "Foo" : "bar_idx" to env. It could help with naming containers or for stateful services with data replication mechanisms. Though it kind of breaks the dynamic nature of mesos/marathon there are tools around which still rely on unique naming of cluster members and require some script or mechanism to habdle it outside the mesos/marathon framework |
@sepiroth887 that's very similar to #1242. Maybe we should reopen this. |
That'd be nice :) I also thought of another thing though: What about a build in variable store? It would allow other tools to keep them up to date by whatever logic they require and can be audited/viewed quite easily that way too |
@sepiroth887 Even though it is not trivial to implement, I like this related idea: #1863 |
That'd do just fine :) |
@kolloch Thanks for taking a look at this! By Being expanding variables Marathon knows in places such as |
follow |
Hi @F21, as far as I know, Marathon cannot know the IP of the host your task is launched on via the Scheduler API of Mesos. For variable substitution, it would be helpful if you came up with specific examples of syntax & use cases. |
One use-case would be to get Marathon variables expanded in the {
"id":"ceph",
"cpus":0.3,
"mem":256,
"instances":1,
"maxLaunchDelaySeconds":36000,
"container":{
"docker":{
"image":"ceph/demo:latest",
"network":"HOST"
}
},
"env":{
"CEPH_NETWORK":"192.168.33.0/24",
"MON_IP": "$HOST"
}
} |
I'd like to expand variables in the {
"id": "app",
"cpus": 0.25,
"mem": 256,
"instances": 1,
"container": {
"type": "DOCKER",
"docker": {
"image": "private-registry.example.com/ns/app:version"
},
"volumes": [
{
"hostPath": "/mnt/blobs/$MESOS_TASK_ID",
"containerPath": "/var/log/app",
"mode": "RW"
}
]
}
} |
The use case for me would be to pass environment variables to the docker image without having to fork it and adapt it to work. For example, I need to specify where some configuration folder is (which is in my
|
Throwing out another example where the expansion in This doesn't work:
Notice I need all three ports in different places. This workaround in JSON 😞
|
This is a very very challenging thing for Marathon to even attempt to implement. In the example provided by @flungo it is quite literally impossible for Marathon to resolved the value of The real solution to this problem probably involves an upstream change to Mesos. One approach could be to create a file containing all of the environment variables that are declared on the |
@BenWhitehead I have found that I think the best way to do this, may be to have it expanded by the shell (possibly through a generated file that is given to the container and sourced before the entrypoint/cmd). This way it is guaranteed that every environment variable that is available at runtime for the container can be expanded into the given environment variables. Not sure if this would be useful or risky but this could also lead to being able to expand all shell syntax such as |
@flungo I think we're mostly in agreement. I feel the shell is the only appropriate location for this expansion to take place. Part of my point is that |
Note: This issue has been migrated to https://jira.mesosphere.com/browse/MARATHON-3002. For more information see https://groups.google.com/forum/#!topic/marathon-framework/khtvf-ifnp8. |
Posted this in the google group and would love to see it as an enhancement: https://groups.google.com/forum/#!topic/marathon-framework/lVNyLTCAipU
I would love to see:
This would allow people to satisfy a lot of requirements of docker containers in the wild and reduce the need to build their own fork to get it to work with marathon.
The text was updated successfully, but these errors were encountered: