You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/website/docs/command-reference/dev.md
+108
Original file line number
Diff line number
Diff line change
@@ -244,6 +244,114 @@ The following command will override the `USER` Devfile variable with the `john`
244
244
odo dev --var USER=john --var-file config.vars
245
245
```
246
246
247
+
248
+
### Using custom port mapping for port forwarding
249
+
Custom local ports can be passed for port forwarding with the help of the `--port-forward` flag. This feature is supported on both podman and cluster.
250
+
251
+
This feature can be helpful when you want to provide consistent and predictable port numbers and avoid being assigned a potentially different port number every time `odo dev` is run.
252
+
253
+
Supported formats for this flag include:
254
+
1. `<LOCAL_PORT>:<CONTAINER_PORT>`
255
+
2. `<LOCAL_PORT>:<CONTAINER_NAME>:<CONTAINER_PORT>` - This format is necessary when multiple container components of a Devfile have the same port number.
256
+
257
+
The flag accepts a stringArray, so `--port-forward` flag can be defined multiple times.
258
+
259
+
If a custom port mapping is not defined for a port, `odo` will assign a free port in the range of 20001-30001.
260
+
261
+
```shell
262
+
odo dev --port-forward <LOCAL_PORT_1>:<CONTAINER_PORT_1> --port-forward <LOCAL_PORT_2>:<CONTAINER_NAME>:<CONTAINER_PORT_2>
263
+
```
264
+
265
+
<details>
266
+
<summary>Example</summary>
267
+
268
+
```shell
269
+
$ odo dev --port-forward 3000:runtime:3000 --port-forward 5000:5858 --debug
270
+
__
271
+
/ \__ Developing using the "my-nodejs-app" Devfile
272
+
\__/ \ Namespace: default
273
+
/ \__/ odo version: v3.9.0
274
+
\__/
275
+
276
+
⚠ You are using "default" namespace, odo may not work as expected in the default namespace.
277
+
⚠ You may set a new namespace by running `odo create namespace <name>`, or set an existing one by running `odo set namespace <name>`
278
+
279
+
↪ Running on the cluster in Dev mode
280
+
• Waiting for Kubernetes resources ...
281
+
⚠ Pod is Pending
282
+
✓ Pod is Running
283
+
✓ Syncing files into the container [152ms]
284
+
✓ Building your application in container (command: install) [27s]
285
+
• Executing the application (command: debug) ...
286
+
✓ Waiting for the application to be ready [1s]
287
+
- Forwarding from 127.0.0.1:8000 -> 3000
288
+
289
+
- Forwarding from 127.0.0.1:5000 -> 5858
290
+
291
+
292
+
↪ Dev mode
293
+
Status:
294
+
Watching for changes in the current directory /tmp/nodejs-debug-2
295
+
296
+
Keyboard Commands:
297
+
[Ctrl+c] - Exit and delete resources from the cluster
298
+
[p] - Manually apply local changes to the application on the cluster
299
+
```
300
+
</details>
301
+
302
+
Note that `--random-ports` flag cannot be used with `--port-forward` flag.
303
+
304
+
### Using custom address for port forwarding
305
+
A custom address can be passed for port forwarding with the help of `--address` flag. This feature is supported on both podman and cluster.
306
+
The default value is 127.0.0.1.
307
+
308
+
```shell
309
+
odo dev --address <IP_ADDRESS>
310
+
```
311
+
312
+
<details>
313
+
<summary>Example</summary>
314
+
315
+
```shell
316
+
$ odo dev --address 127.0.10.3
317
+
__
318
+
/ \__ Developing using the "my-nodejs-app" Devfile
319
+
\__/ \ Namespace: default
320
+
/ \__/ odo version: v3.9.0
321
+
\__/
322
+
323
+
⚠ You are using "default" namespace, odo may not work as expected in the default namespace.
324
+
⚠ You may set a new namespace by running `odo create namespace <name>`, or set an existing one by running `odo set namespace <name>`
325
+
326
+
↪ Running on the cluster in Dev mode
327
+
• Waiting for Kubernetes resources ...
328
+
⚠ Pod is Pending
329
+
✓ Pod is Running
330
+
✓ Syncing files into the container [123ms]
331
+
✓ Building your application in container (command: install) [15s]
332
+
• Executing the application (command: run) ...
333
+
✓ Waiting for the application to be ready [1s]
334
+
- Forwarding from 127.0.10.3:20001 -> 3000
335
+
336
+
337
+
↪ Dev mode
338
+
Status:
339
+
Watching forchangesin the current directory /tmp/nodejs-debug-2
340
+
341
+
Keyboard Commands:
342
+
[Ctrl+c] - Exit and delete resources from the cluster
343
+
[p] - Manually apply local changes to the application on the cluster
344
+
```
345
+
</details>
346
+
347
+
:::note
348
+
If you are on macOS and using a Cluster platform, you may not be able to run multiple Dev sessions in parallel on address 0.0.0.0 without defining a custom port mapping, or using a different or default address.
349
+
350
+
For more information, see the following issues:
351
+
1. [Cannot start 2 different Dev sessions on Podman due to conflicting host ports](https://github.com/redhat-developer/odo/issues/6612)
352
+
2. [[MacOS] Cannot run 2 dev sessions simultaneously on cluster](https://github.com/redhat-developer/odo/issues/6744)
353
+
:::
354
+
247
355
### Running on Podman
248
356
249
357
Instead of deploying the container into a Kubernetes cluster, `odo dev` can leverage the podman installation on your system to deploy the container.
Copy file name to clipboardExpand all lines: pkg/dev/interface.go
+2
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,8 @@ type StartOptions struct {
22
22
RandomPortsbool
23
23
// CustomForwardedPorts define custom ports for port forwarding
24
24
CustomForwardedPorts []api.ForwardedPort
25
+
// CustomAddress defines a custom local address for port forwarding; default value is 127.0.0.1
26
+
CustomAddressstring
25
27
// if WatchFiles is set, files changes will trigger a new sync to the container
26
28
WatchFilesbool
27
29
// IgnoreLocalhost indicates whether to proceed with port-forwarding regardless of any container ports being bound to the container loopback interface.
0 commit comments