Skip to content
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

use adminport instead of host network #1176

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions client/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"os/exec"
"os/user"
"regexp"
"runtime"
"strconv"
"strings"
"text/template"
Expand Down Expand Up @@ -596,7 +597,7 @@ func (cli *VanClient) setupGatewayConfig(ctx context.Context, gatewayName string
}
gatewayConfig.Listeners["amqp"] = qdr.Listener{
Name: "amqp",
Host: "localhost",
Host: "0.0.0.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ajssmith this is exposing the AMQP port to 0.0.0.0 instead.
Do you see any issue with it?

Port: int32(amqpPort),
}

Expand Down Expand Up @@ -735,6 +736,16 @@ func (cli *VanClient) gatewayStartContainer(ctx context.Context, gatewayName str
}

siteId, _ := getGatewaySiteId(gatewayDir)
adminUrl, _ := getRouterUrl(gatewayDir)
adminPort := strings.Split(adminUrl, ":")

networkingFlag := "--network"
networkingValue := "host"
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
networkingFlag = "-p"
networkingValue = adminPort[len(adminPort)-1] + ":" + adminPort[len(adminPort)-1]
}

containerCmd := gatewayType
containerCmdArgs := []string{
"run",
Expand All @@ -743,8 +754,8 @@ func (cli *VanClient) gatewayStartContainer(ctx context.Context, gatewayName str
"-d",
"--name",
gatewayName,
"--network",
"host",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this would break gateway forward as host ports won't be bound
to the gateway container.

Copy link
Author

@hguerrero hguerrero Jul 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is already broken in non-Linux systems. IIRC, the recommended way to proceed for Linux systems is using podman sites instead. If it is not the case, then we can add a flag to detect the OS running and keep --network host for the ones where it is supported (at the moment, only Linux).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding an OS specific customization in this case, makes more sense to me as well.

Eventually, if the host network cannot be used in non-Linux systems, I believe we'd also need to disable
the forward command (for now), as the alternative to make it work with the bridge driver, would be to
redefine the container, so that the extra forward (host) ports can be bound to the container.

@ajssmith thoughts?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fgiorgetti Added a check to get the host OS and only do port mapping for windows and darwin.

networkingFlag,
networkingValue,
"-e",
"SKUPPER_SITE_ID=gateway" + "_" + gatewayName + "_" + siteId,
"-e",
Expand Down