-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable port forwarding on host #10488
Enable port forwarding on host #10488
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: baude The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Ah, always parsing the --network flag breaks diff --git a/cmd/podman/pods/create.go b/cmd/podman/pods/create.go
index 5600d8794..ce12b386c 100644
--- a/cmd/podman/pods/create.go
+++ b/cmd/podman/pods/create.go
@@ -171,6 +171,20 @@ func create(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
+
+ net, err := cmd.Flags().GetString("network")
+ if err != nil {
+ return err
+ }
+
+ // If there is no infra container and the network flag was not set or set to "" or "default"
+ // set the the network namespace back to the default value. This is needed because
+ // NetFlagsToNetOptions sets the nsmode to either slirp or bridge in such case and specgen
+ // complains when a nsmode other than default is used with no infra container.
+ if !createOptions.Infra && (!cmd.Flag("network").Changed || net == "" || net == "default") {
+ createOptions.Net.Network = specgen.Namespace{NSMode: specgen.Default}
+ }
+
if len(createOptions.Net.PublishPorts) > 0 {
if !createOptions.Infra {
return errors.Errorf("you must have an infra container to publish port bindings to the host") |
@Luap99 fixed, thanks! |
All kinds of test unhappiness @baude |
Sorry @baude, my previous fix broke other things. diff --git a/cmd/podman/common/netflags.go b/cmd/podman/common/netflags.go
index bdd642d74..20f8c0a79 100644
--- a/cmd/podman/common/netflags.go
+++ b/cmd/podman/common/netflags.go
@@ -198,20 +198,22 @@ func NetFlagsToNetOptions(cmd *cobra.Command) (*entities.NetOptions, error) {
return nil, err
}
- parts := strings.SplitN(network, ":", 2)
+ if network != "" {
+ parts := strings.SplitN(network, ":", 2)
- ns, cniNets, err := specgen.ParseNetworkNamespace(network, containerConfig.Containers.RootlessNetworking == "cni")
- if err != nil {
- return nil, err
- }
+ ns, cniNets, err := specgen.ParseNetworkNamespace(network, containerConfig.Containers.RootlessNetworking == "cni")
+ if err != nil {
+ return nil, err
+ }
- if len(parts) > 1 {
- opts.NetworkOptions = make(map[string][]string)
- opts.NetworkOptions[parts[0]] = strings.Split(parts[1], ",")
- cniNets = nil
+ if len(parts) > 1 {
+ opts.NetworkOptions = make(map[string][]string)
+ opts.NetworkOptions[parts[0]] = strings.Split(parts[1], ",")
+ cniNets = nil
+ }
+ opts.Network = ns
+ opts.CNINetworks = cniNets
}
- opts.Network = ns
- opts.CNINetworks = cniNets
aliases, err := cmd.Flags().GetStringSlice("network-alias")
if err != nil { Edit: This also doesn't work. I will take a look tomorrow but the main problem is that c/common is forcing brige/slirp as --network value. |
Using the gvproxy application on the host, we can now port forward from the machine vm on the host. It requires that 'gvproxy' be installed in an executable location. gvproxy can be found in the containers/gvisor-tap-vsock github repo. [NO TESTS NEEDED] Signed-off-by: Brent Baude <bbaude@redhat.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/lgtm |
Using the gvproxy application on the host, we can now port forward from
the machine vm on the host. It requires that 'gvproxy' be installed in
an executable location. gvproxy can be found in the
containers/gvisor-tap-vsock github repo.
[NO TESTS NEEDED]
Signed-off-by: Brent Baude bbaude@redhat.com