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

Commit

Permalink
Merge pull request #4804 from hashicorp/b-install-nomad-network
Browse files Browse the repository at this point in the history
install/nomad: Add host network config option.
  • Loading branch information
paladin-devops authored Jun 14, 2023
2 parents ed4b99d + 6bd20ee commit adf636b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .changelog/4804.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```release-note:improvement
serverinstall/nomad: Add config flag `-nomad-host-network` for specifying the
host network of the Waypoint server Nomad job's gRPC and HTTP (UI) ports.
```
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 adf636b

Please sign in to comment.