Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
install/nomad: Add host network config option.
Browse files Browse the repository at this point in the history
This enables users to configure the networking of the Waypoint server Nomad job to use a host network other than one named "default", for the gRPC and HTTP (UI) server ports.
  • Loading branch information
paladin-devops committed Jun 13, 2023
1 parent ed4b99d commit e2e5b7b
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
Empty file added .changelog/4804.txt
Empty file.
36 changes: 30 additions & 6 deletions internal/serverinstall/nomad.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type nomadConfig struct {
serviceBackendTags []string `hcl:"service_backend_tags:optional"`
serviceAddress string `hcl:"service_address,optional"`
networkMode string `hcl:"network_mode,optional"`
hostNetwork string `hcl:"host_network,optional"`

consulService bool `hcl:"consul_service,optional"`
consulServiceUITags []string `hcl:"consul_service_ui_tags:optional"`
Expand Down Expand Up @@ -908,20 +909,27 @@ func waypointNomadJob(c nomadConfig, rawRunFlags []string, upgrade bool) *api.Jo
}
tg.Services = services

hostNetwork := "default"
if c.hostNetwork != "" {
hostNetwork = c.hostNetwork
}

tg.Networks = []*api.NetworkResource{
{
Mode: c.networkMode,
// currently set to static; when ui command can be dynamic - update this
ReservedPorts: []api.Port{
{
Label: "ui",
Value: httpPort,
To: httpPort,
Label: "ui",
Value: httpPort,
To: httpPort,
HostNetwork: hostNetwork,
},
{
Label: "server",
To: grpcPort,
Value: grpcPort,
Label: "server",
To: grpcPort,
Value: grpcPort,
HostNetwork: hostNetwork,
},
},
},
Expand Down Expand Up @@ -1178,6 +1186,14 @@ func (i *NomadInstaller) InstallFlags(set *flag.Set) {
Default: "host",
})

set.StringVar(&flag.StringVar{
Name: "nomad-host-network",
Target: &i.config.hostNetwork,
Usage: "Designates the host network name to use when allocating the" +
" ports of the Waypoint server.",
Default: "default",
})

set.StringVar(&flag.StringVar{
Name: "nomad-odr-image",
Target: &i.config.odrImage,
Expand Down Expand Up @@ -1466,6 +1482,14 @@ func (i *NomadInstaller) UpgradeFlags(set *flag.Set) {
Default: "host",
})

set.StringVar(&flag.StringVar{
Name: "nomad-host-network",
Target: &i.config.hostNetwork,
Usage: "Designates the host network name to use when allocating the" +
" ports of the Waypoint server.",
Default: "default",
})

set.StringVar(&flag.StringVar{
Name: "nomad-odr-image",
Target: &i.config.odrImage,
Expand Down
1 change: 1 addition & 0 deletions website/content/commands/install.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ and disable the UI, the command would be:
- `-nomad-host=<string>` - Hostname of the Nomad server to use, like for launching on-demand tasks. The default is http://localhost:4646.
- `-nomad-namespace=<string>` - Namespace to install the Waypoint server into for Nomad. The default is default.
- `-nomad-network-mode=<string>` - Nomad task group network mode. The default is host.
- `-nomad-host-network=<string>` - Designates the host network name to use when allocating the ports of the Waypoint server. The default is default.
- `-nomad-odr-image=<string>` - Docker image for the on-demand runners. If not specified, it defaults to the server image name + '-odr' (i.e. 'hashicorp/waypoint-odr:latest').
- `-nomad-policy-override` - Override the Nomad sentinel policy for enterprise Nomad. The default is false.
- `-nomad-region=<string>` - Region to install to for Nomad. The default is global.
Expand Down
1 change: 1 addition & 0 deletions website/content/commands/server-install.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ and disable the UI, the command would be:
- `-nomad-host=<string>` - Hostname of the Nomad server to use, like for launching on-demand tasks. The default is http://localhost:4646.
- `-nomad-namespace=<string>` - Namespace to install the Waypoint server into for Nomad. The default is default.
- `-nomad-network-mode=<string>` - Nomad task group network mode. The default is host.
- `-nomad-host-network=<string>` - Designates the host network name to use when allocating the ports of the Waypoint server. The default is default.
- `-nomad-odr-image=<string>` - Docker image for the on-demand runners. If not specified, it defaults to the server image name + '-odr' (i.e. 'hashicorp/waypoint-odr:latest').
- `-nomad-policy-override` - Override the Nomad sentinel policy for enterprise Nomad. The default is false.
- `-nomad-region=<string>` - Region to install to for Nomad. The default is global.
Expand Down
1 change: 1 addition & 0 deletions website/content/commands/server-upgrade.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ manually installed runners will not be automatically upgraded.
- `-nomad-host=<string>` - Hostname of the Nomad server to use, like for launching on-demand tasks. The default is http://localhost:4646.
- `-nomad-namespace=<string>` - Namespace to install the Waypoint server into for Nomad. The default is default.
- `-nomad-network-mode=<string>` - Nomad task group network mode. The default is host.
- `-nomad-host-network=<string>` - Designates the host network name to use when allocating the ports of the Waypoint server. The default is default.
- `-nomad-odr-image=<string>` - Docker image for the on-demand runners. If not specified, it defaults to the server image name + '-odr' (i.e. 'hashicorp/waypoint-odr:latest').
- `-nomad-policy-override` - Override the Nomad sentinel policy for enterprise Nomad. The default is false.
- `-nomad-region=<string>` - Region to install to for Nomad. The default is global.
Expand Down

0 comments on commit e2e5b7b

Please sign in to comment.