Feature: Set port config while creating initial devfile `odo init nodejs frontend --port 8080`
/kind feature
Which functionality do you think we should add?
It would be really nice to have a --port option for odo create that would allow users to modify and/or extend the catalog devfile examples. This currently works for --s2i, but is not yet available for devfiles.
Why is this needed?
The default nodejs devfile example (from the registry catalog) binds to 3000 by default. This works well for the --starter repo, but binding to port 3000 is not used exclusively by all nodejs projects. Users can run odo config set Ports 8080 as a workaround, but this seems to append additional port info instead of replacing the older config.
Here is a clip from my resulting devfile.yaml using odo v2.0.5 (e8030b19a):
- container:
endpoints:
- name: http-3000
targetPort: 3000
- name: port-8080-tcp
protocol: tcp
targetPort: 8080
Currently, users who take this approach will end up with two routes after running odo push. Clicking on the "Open URL" decorator in the Topology view fails - unless the user cleans up the invalid port config using oc delete route http-3000-frontend
Ideally, users should be able to set the port config during the initial devfile creation step, via odo create nodejs component_name --port 8080
See the "frontend" component here for an example nodejs app that binds to 8080: https://learn.openshift.com/introduction/developing-with-odo/
@girishramnani this is exactly what you were talking about yesterday.
Issues go stale after 90d of inactivity.
Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.
If this issue is safe to close now please do so with /close.
/lifecycle stale
Stale issues rot after 30d of inactivity.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.
If this issue is safe to close now please do so with /close.
/lifecycle rotten /remove-lifecycle stale
/remove-lifecycle rotten
@kadel can you PTAL?
Issues go stale after 90d of inactivity.
Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.
If this issue is safe to close now please do so with /close.
/lifecycle stale
Stale issues rot after 30d of inactivity.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.
If this issue is safe to close now please do so with /close.
/lifecycle rotten /remove-lifecycle stale
/remove-lifecycle rotten
@kadel can you PTAL?
/remove-lifecycle rotten
@kadel can you please help set priority on this one?
Any updates on this? It's needed to support our default nodejs example app
hey @dharmit @kadel will this work with odo v3?
I've tried using --port 8080, and I've tried the alternative, moving the app to :3000 via --env PORT=3000.
Both options (--port and --env) don't seem to get reflected in the devfile.yaml that is generated. I tried with odo version 2.5.0 and version 3.0.0beta2
Our example app runs on :8080 by default, and can be configured using the PORT env variable: https://github.com/sclorg/nodejs-ex
Let me know if you have any tips on how to set it up using odo and a local copy of the git repo:
- git clone https://github.com/sclorg/nodejs-ex
- cd nodejs-ex
- odo init nodejs frontend --port 8080
Or alternatively...
- odo init nodejs frontend --env PORT=3000
I'm able to successfully edit the resulting devfile.yaml to include my PORT=3000 environment setting. But, I'm not able figure out how to add these environment variables (or how to use the --port option) using odo's command line flags.
With odo v3, there's yet no direct way of passing a flag to odo init command to get this done, but you could do it via interactive mode.
In the directory where your code resides, run odo init (make sure there's no devfile.yaml file in this directory) without any arguments. odo will ask you a bunch of questions. First, it will ask you if the language/framework it detected based on the code in your pwd is correct. If not, you can interactively change the framework.
Next, it will let you modify env vars for the "runtime" container. By default, port for this is 3000. You should delete the port and add 8080. All of this through interactive mode.
Thanks @dharmit, @serenamarie125
This works for me in interactive mode with v3.0.0beta2
Looking forward to a non-interactive way to generate a devfile as well - which might also resolve #4435