Skip to content

[WIP][To delete] Fix access to local ports forwarded to container apps listening on the loopback interface on Podman#6589

Closed
rm3l wants to merge 11 commits intoredhat-developer:mainfrom
rm3l:6510-on-podman-unable-to-access-local-ports-forwarded-to-container-applications-listening-on-the-loopback-interface-e.g.-debug-endpoints
Closed

[WIP][To delete] Fix access to local ports forwarded to container apps listening on the loopback interface on Podman#6589
rm3l wants to merge 11 commits intoredhat-developer:mainfrom
rm3l:6510-on-podman-unable-to-access-local-ports-forwarded-to-container-applications-listening-on-the-loopback-interface-e.g.-debug-endpoints

Conversation

@rm3l
Copy link
Member

@rm3l rm3l commented Feb 10, 2023

What type of PR is this:
/kind bug
/area odo-on-podman

What does this PR do / why we need it:
TODO

Which issue(s) this PR fixes:
Fixes #6510

PR acceptance criteria:

  • Unit test

  • Integration test

  • Documentation

How to test changes / Special notes to the reviewer:
See #6510 for the reproduction steps.

rm3l added 4 commits February 10, 2023 14:42
This avoids repeating the same methods in both interfaces,
and makes the intent clearer.
This is recommended in the Coding Conventions guidelines [1].
Specifically, what's important here is checking that it meets the 'platform.Client' contract.

[1] https://github.com/redhat-developer/odo/wiki/Dev:-Coding-Conventions#verify-interface-compliance
…ckage

This paves the way to providing a different implementation for Podman
Current implementation relies on the Devfile object,
so it makes more sense to be in the libdevfile package.
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. label Feb 10, 2023
@netlify
Copy link

netlify bot commented Feb 10, 2023

Deploy Preview for odo-docusaurus-preview canceled.

Name Link
🔨 Latest commit ebff301
🔍 Latest deploy log https://app.netlify.com/sites/odo-docusaurus-preview/deploys/63e67b4fdb171c000961e9e1

@openshift-ci
Copy link

openshift-ci bot commented Feb 10, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci bot added kind/bug Categorizes issue or PR as related to a bug. area/odo-on-podman Issues or PRs related to running odo against Podman labels Feb 10, 2023
@odo-robot
Copy link

odo-robot bot commented Feb 10, 2023

Validate Tests on commit d7a84d2 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Feb 10, 2023

NoCluster Tests on commit d7a84d2 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Feb 10, 2023

OpenShift Unauthenticated Tests on commit d7a84d2 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Feb 10, 2023

Unit Tests on commit d7a84d2 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Feb 10, 2023

Kubernetes Tests on commit d7a84d2 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Feb 10, 2023

Windows Tests (OCP) on commit d7a84d2 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Feb 10, 2023

OpenShift Tests on commit d7a84d2 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Feb 10, 2023

Kubernetes Docs Tests on commit ad77fe7 finished successfully.
View logs: TXT HTML

…mmand process

This allows callers to get more meaningful events about the process.
@rm3l rm3l force-pushed the 6510-on-podman-unable-to-access-local-ports-forwarded-to-container-applications-listening-on-the-loopback-interface-e.g.-debug-endpoints branch from 5db1cac to ebce981 Compare February 10, 2023 16:54
rm3l added 6 commits February 10, 2023 18:13
As explained in [1], this makes use of a helper sidecar container
(aptly named "odo-helper-port-forwarding") to be added to the Pod Spec created by odo.
In this scope, port-forwarding will be equivalent of executing a socat command in this
helper container, like so:

socat -d tcp-listen:20002,reuseaddr,fork tcp:localhost:5858

In the command above, this will open up port 20001 on the helper container,
and forwarding requests to localhost:5858
(which would be in the application container, part of the same Pod)

[1] redhat-developer#6510
Specifically, the 'StartPortForwarding' method
can now accept an explicit list of ports that needs to
be forwarded, if the caller can compute provide such information.

This is currently useful on Podman where the ports
(even the random ones) are known in advance.
As explained in [1], this helper sidecar container (aptly named "odo-helper-port-forwarding")
will hold the actual container/host ports mapping in the spec
(to overcome the limitation of using hostPort against a container app listening on the loopback interface);
this running container will be used to execute the actual port-forwarding commands (based on socat), e.g:

```
apiVersion: v1
kind: Pod
metadata:
  name: my-component-app
  labels:
    app: my-component-app
spec:
  containers:
  - name: runtime
    command: [ 'tail', '-f', '/dev/null']
    # Omitted for brevity, but imagine an application being executed by odo
    # and listening on both 0.0.0.0:3000 and 127.0.0.1:5858

  - name: odo-helper-port-forwarding
    image: quay.io/devfile/base-developer-image:ubi8-latest
    command: [ 'tail', '-f', '/dev/null']
    ports:
    - containerPort: 20001
      # A command will be executed by odo, e.g.: 'socat -d -d tcp-listen:20001,reuseaddr,fork tcp:localhost:3000'
      hostPort: 20001
    - containerPort: 20002
      # A command will be executed by odo, e.g.: 'socat -d -d tcp-listen:20002,reuseaddr,fork tcp:localhost:5858'
      hostPort: 20002

# ... Omitted for brevity
```

In this scope, port-forwarding from 20002 to 5858 for example will be equivalent of executing
a socat command in this helper container, like so:

socat -d tcp-listen:20002,reuseaddr,fork tcp:localhost:5858

In the command above, this will open up port 20001 on the helper container,
and forwarding requests to localhost:5858
(which would be in the 'runtime' container, part of the same Pod)

[1] redhat-developer#6510
@rm3l rm3l force-pushed the 6510-on-podman-unable-to-access-local-ports-forwarded-to-container-applications-listening-on-the-loopback-interface-e.g.-debug-endpoints branch from ebce981 to ebff301 Compare February 10, 2023 17:13
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 5 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@rm3l rm3l changed the title [WIP] Fix access to local ports forwarded to container apps listening on the loopback interface on Podman [WIP][To delete] ~Fix access to local ports forwarded to container apps listening on the loopback interface on Podman~ Mar 1, 2023
@rm3l rm3l changed the title [WIP][To delete] ~Fix access to local ports forwarded to container apps listening on the loopback interface on Podman~ [WIP][To delete] Fix access to local ports forwarded to container apps listening on the loopback interface on Podman Mar 1, 2023
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. label Mar 2, 2023
@openshift-merge-robot
Copy link
Collaborator

PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@rm3l
Copy link
Member Author

rm3l commented Mar 2, 2023

Closed in favor of #6629

@rm3l rm3l closed this Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/odo-on-podman Issues or PRs related to running odo against Podman do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. Required by Prow. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. kind/bug Categorizes issue or PR as related to a bug. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

On Podman, unable to access local ports forwarded to container applications listening on the loopback interface (e.g. debug endpoints)

2 participants