From d73c31a4ccbcd2d757b374f0474c55979230f32a Mon Sep 17 00:00:00 2001 From: paladin-devops Date: Wed, 20 Apr 2022 21:02:00 +0000 Subject: [PATCH 1/6] backport of commit 5029d3bd47a2d42d0989fa4bd2fedc075a5b54ad --- internal/serverinstall/nomad.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/serverinstall/nomad.go b/internal/serverinstall/nomad.go index 892c8017190..5320fa80dc7 100644 --- a/internal/serverinstall/nomad.go +++ b/internal/serverinstall/nomad.go @@ -4,6 +4,7 @@ import ( "context" json "encoding/json" "fmt" + "os" "strconv" "strings" "time" @@ -856,6 +857,8 @@ func waypointNomadJob(c nomadConfig, rawRunFlags []string) *api.Job { // Include services to be registered in Consul. Currently configured to happen by default // One service added for Waypoint UI, and one for Waypoint backend port if c.consulService { + token := os.Getenv("CONSUL_HTTP_TOKEN") + job.ConsulToken = &token tg.Services = []*api.Service{ { Name: waypointConsulUIName, @@ -943,7 +946,7 @@ func waypointNomadJob(c nomadConfig, rawRunFlags []string) *api.Job { tg.AddTask(preTask) - ras := []string{"server", "run", "-accept-tos", "-vv", "-db=/alloc/data/data.db", fmt.Sprintf("-listen-grpc=0.0.0.0:%s", defaultGrpcPort), fmt.Sprintf("-listen-http=0.0.0.0:%s", defaultHttpPort)} + ras := []string{"server", "run", "-accept-tos", "-vv", "-db=/data/data.db", fmt.Sprintf("-listen-grpc=0.0.0.0:%s", defaultGrpcPort), fmt.Sprintf("-listen-http=0.0.0.0:%s", defaultHttpPort)} ras = append(ras, rawRunFlags...) task := api.NewTask("server", "docker") task.Config = map[string]interface{}{ From 6d4102e77557e79d349b9d116d30ef9863b1d83a Mon Sep 17 00:00:00 2001 From: paladin-devops Date: Wed, 20 Apr 2022 21:12:02 +0000 Subject: [PATCH 2/6] backport of commit 0838e3d8dcb24eead8bb293df8431b6f0ff861b2 --- .changelog/3261.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/3261.txt diff --git a/.changelog/3261.txt b/.changelog/3261.txt new file mode 100644 index 00000000000..33db2beeaaf --- /dev/null +++ b/.changelog/3261.txt @@ -0,0 +1,3 @@ +```release-note:bug +install/nomad: Fix DB directory for Nomad install +``` From 68cb5e64c7c35719f5569b520fded9045481a1f2 Mon Sep 17 00:00:00 2001 From: paladin-devops Date: Thu, 28 Apr 2022 17:59:38 +0000 Subject: [PATCH 3/6] backport of commit 6c7895eaa57a64982324c5ff7ccf788b24d2b756 --- internal/serverinstall/nomad.go | 32 +++++++++++++++++++-- website/content/commands/server-install.mdx | 8 ++++-- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/internal/serverinstall/nomad.go b/internal/serverinstall/nomad.go index 5320fa80dc7..e73052eb1e8 100644 --- a/internal/serverinstall/nomad.go +++ b/internal/serverinstall/nomad.go @@ -36,6 +36,7 @@ type nomadConfig struct { consulServiceBackendTags []string `hcl:"consul_service_backend_tags:optional"` consulDatacenter string `hcl:"consul_datacenter,optional"` consulDomain string `hcl:"consul_datacenter,optional"` + consulToken string `hcl:"consul_token,optional"` // If set along with consul, will use this hostname instead of // making a consul DNS hostname for the server address in its context @@ -53,6 +54,7 @@ type nomadConfig struct { runnerResourcesMemory string `hcl:"runner_resources_memory,optional"` hostVolume string `hcl:"host_volume,optional"` + hostVolumePath string `hcl:"host_volume_path,optional"` csiVolumeProvider string `hcl:"csi_volume_provider,optional"` csiVolumeCapacityMin int64 `hcl:"csi_volume_capacity_min,optional"` csiVolumeCapacityMax int64 `hcl:"csi_volume_capacity_max,optional"` @@ -857,7 +859,12 @@ func waypointNomadJob(c nomadConfig, rawRunFlags []string) *api.Job { // Include services to be registered in Consul. Currently configured to happen by default // One service added for Waypoint UI, and one for Waypoint backend port if c.consulService { - token := os.Getenv("CONSUL_HTTP_TOKEN") + token := "" + if c.consulToken == "" { + token = os.Getenv("CONSUL_HTTP_TOKEN") + } else { + token = c.consulToken + } job.ConsulToken = &token tg.Services = []*api.Service{ { @@ -928,11 +935,18 @@ func waypointNomadJob(c nomadConfig, rawRunFlags []string) *api.Job { // Observed WP user and group IDs in the published container, update if those ever change waypointUserID := 100 waypointGroupID := 1000 + // Used by busybox pre-task to set permissions on the directory Waypoint will use + volumePath := "" + if c.hostVolumePath != "" && volumeRequest.Type == "host" { + volumePath = c.hostVolumePath + } else { + volumePath = "/data/" + } preTask.Config = map[string]interface{}{ // Doing this because this is the only way https://github.com/hashicorp/nomad/issues/8892 "image": "busybox:latest", "command": "sh", - "args": []string{"-c", fmt.Sprintf("chown -R %d:%d /data/", waypointUserID, waypointGroupID)}, + "args": []string{"-c", fmt.Sprintf("chown -R %d:%d %s", waypointUserID, waypointGroupID, volumePath)}, } preTask.VolumeMounts = volumeMounts preTask.Resources = &api.Resources{ @@ -1252,12 +1266,26 @@ func (i *NomadInstaller) InstallFlags(set *flag.Set) { Default: defaultConsulDomain, }) + set.StringVar(&flag.StringVar{ + Name: "nomad-consul-token", + Target: &i.config.consulToken, + Usage: "If set, the passed Consul token is stored in the job " + + "before sending to the Nomad servers. Overrides the CONSUL_HTTP_TOKEN " + + "environment variable if set.", + }) + set.StringVar(&flag.StringVar{ Name: "nomad-host-volume", Target: &i.config.hostVolume, Usage: "Nomad host volume name, required for volume type 'host'.", }) + set.StringVar(&flag.StringVar{ + Name: "nomad-host-volume-path", + Target: &i.config.hostVolumePath, + Usage: "Path of the host volume for Waypoint on the Nomad client.", + }) + set.StringVar(&flag.StringVar{ Name: "nomad-csi-volume-provider", Target: &i.config.csiVolumeProvider, diff --git a/website/content/commands/server-install.mdx b/website/content/commands/server-install.mdx index 97c9af2bc0a..25472c7bbac 100644 --- a/website/content/commands/server-install.mdx +++ b/website/content/commands/server-install.mdx @@ -1,8 +1,8 @@ --- layout: commands -page_title: 'Commands: Server install' -sidebar_title: 'server install' -description: 'Install the Waypoint server to Kubernetes, Nomad, ECS, or Docker' +page_title: "Commands: Server install" +sidebar_title: "server install" +description: "Install the Waypoint server to Kubernetes, Nomad, ECS, or Docker" --- # Waypoint Server install @@ -119,7 +119,9 @@ and disable the UI, the command would be: - `-nomad-consul-service-backend-tags=` - Tags for the Waypoint backend service generated in Consul. The 'first' tag will be used when crafting the Consul DNS hostname for accessing Waypoint. - `-nomad-consul-datacenter=` - The datacenter where Consul is located. - `-nomad-consul-domain=` - The domain where Consul is located. +- `-nomad-consul-token=` - If set, the passed Consul token is stored in the job before sending to the Nomad servers. Overrides the CONSUL_HTTP_TOKEN environment variable if set. - `-nomad-host-volume=` - Nomad host volume name, required for volume type 'host'. +- `-nomad-host-volume-path=` - Path of the host volume for Waypoint on the Nomad client. - `-nomad-csi-volume-provider=` - Nomad CSI volume provider, required for volume type 'csi'. - `-nomad-csi-volume-capacity-min=` - Nomad CSI volume capacity minimum, in bytes. - `-nomad-csi-volume-capacity-max=` - Nomad CSI volume capacity maximum, in bytes. From a37623677ec3126655303552ada04a4d2ea1e71f Mon Sep 17 00:00:00 2001 From: paladin-devops Date: Thu, 28 Apr 2022 18:17:36 +0000 Subject: [PATCH 4/6] backport of commit 9000d3dc59939112f8e719549c346bd51f205781 --- website/content/commands/install.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/website/content/commands/install.mdx b/website/content/commands/install.mdx index 5ff30ca33f0..69a53b6cf66 100644 --- a/website/content/commands/install.mdx +++ b/website/content/commands/install.mdx @@ -119,7 +119,9 @@ and disable the UI, the command would be: - `-nomad-consul-service-backend-tags=` - Tags for the Waypoint backend service generated in Consul. The 'first' tag will be used when crafting the Consul DNS hostname for accessing Waypoint. - `-nomad-consul-datacenter=` - The datacenter where Consul is located. - `-nomad-consul-domain=` - The domain where Consul is located. +- `-nomad-consul-token=` - If set, the passed Consul token is stored in the job before sending to the Nomad servers. Overrides the CONSUL_HTTP_TOKEN environment variable if set. - `-nomad-host-volume=` - Nomad host volume name, required for volume type 'host'. +- `-nomad-host-volume-path=` - Path of the host volume for Waypoint on the Nomad client. - `-nomad-csi-volume-provider=` - Nomad CSI volume provider, required for volume type 'csi'. - `-nomad-csi-volume-capacity-min=` - Nomad CSI volume capacity minimum, in bytes. - `-nomad-csi-volume-capacity-max=` - Nomad CSI volume capacity maximum, in bytes. From 7029ba29f39e09fb029627b84a5fa51f2d249911 Mon Sep 17 00:00:00 2001 From: paladin-devops Date: Thu, 28 Apr 2022 19:44:45 +0000 Subject: [PATCH 5/6] backport of commit 1639633e837def76e6ab23efcdaa91877768b60d --- website/content/commands/server-install.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/content/commands/server-install.mdx b/website/content/commands/server-install.mdx index 25472c7bbac..922e902f5f6 100644 --- a/website/content/commands/server-install.mdx +++ b/website/content/commands/server-install.mdx @@ -1,8 +1,8 @@ --- layout: commands -page_title: "Commands: Server install" -sidebar_title: "server install" -description: "Install the Waypoint server to Kubernetes, Nomad, ECS, or Docker" +page_title: 'Commands: Server install' +sidebar_title: 'server install' +description: 'Install the Waypoint server to Kubernetes, Nomad, ECS, or Docker' --- # Waypoint Server install From e06d537d660d0781f54e3bfececab27d48e256d9 Mon Sep 17 00:00:00 2001 From: paladin-devops Date: Fri, 29 Apr 2022 15:19:01 +0000 Subject: [PATCH 6/6] backport of commit 123c662469a4a31814d36b2b830c7de2e8d9e8b8 --- internal/serverinstall/nomad.go | 16 +--------------- website/content/commands/install.mdx | 1 - website/content/commands/server-install.mdx | 1 - 3 files changed, 1 insertion(+), 17 deletions(-) diff --git a/internal/serverinstall/nomad.go b/internal/serverinstall/nomad.go index e73052eb1e8..b5d2e59fd56 100644 --- a/internal/serverinstall/nomad.go +++ b/internal/serverinstall/nomad.go @@ -54,7 +54,6 @@ type nomadConfig struct { runnerResourcesMemory string `hcl:"runner_resources_memory,optional"` hostVolume string `hcl:"host_volume,optional"` - hostVolumePath string `hcl:"host_volume_path,optional"` csiVolumeProvider string `hcl:"csi_volume_provider,optional"` csiVolumeCapacityMin int64 `hcl:"csi_volume_capacity_min,optional"` csiVolumeCapacityMax int64 `hcl:"csi_volume_capacity_max,optional"` @@ -935,18 +934,11 @@ func waypointNomadJob(c nomadConfig, rawRunFlags []string) *api.Job { // Observed WP user and group IDs in the published container, update if those ever change waypointUserID := 100 waypointGroupID := 1000 - // Used by busybox pre-task to set permissions on the directory Waypoint will use - volumePath := "" - if c.hostVolumePath != "" && volumeRequest.Type == "host" { - volumePath = c.hostVolumePath - } else { - volumePath = "/data/" - } preTask.Config = map[string]interface{}{ // Doing this because this is the only way https://github.com/hashicorp/nomad/issues/8892 "image": "busybox:latest", "command": "sh", - "args": []string{"-c", fmt.Sprintf("chown -R %d:%d %s", waypointUserID, waypointGroupID, volumePath)}, + "args": []string{"-c", fmt.Sprintf("chown -R %d:%d /data", waypointUserID, waypointGroupID)}, } preTask.VolumeMounts = volumeMounts preTask.Resources = &api.Resources{ @@ -1280,12 +1272,6 @@ func (i *NomadInstaller) InstallFlags(set *flag.Set) { Usage: "Nomad host volume name, required for volume type 'host'.", }) - set.StringVar(&flag.StringVar{ - Name: "nomad-host-volume-path", - Target: &i.config.hostVolumePath, - Usage: "Path of the host volume for Waypoint on the Nomad client.", - }) - set.StringVar(&flag.StringVar{ Name: "nomad-csi-volume-provider", Target: &i.config.csiVolumeProvider, diff --git a/website/content/commands/install.mdx b/website/content/commands/install.mdx index 69a53b6cf66..e46330c39f0 100644 --- a/website/content/commands/install.mdx +++ b/website/content/commands/install.mdx @@ -121,7 +121,6 @@ and disable the UI, the command would be: - `-nomad-consul-domain=` - The domain where Consul is located. - `-nomad-consul-token=` - If set, the passed Consul token is stored in the job before sending to the Nomad servers. Overrides the CONSUL_HTTP_TOKEN environment variable if set. - `-nomad-host-volume=` - Nomad host volume name, required for volume type 'host'. -- `-nomad-host-volume-path=` - Path of the host volume for Waypoint on the Nomad client. - `-nomad-csi-volume-provider=` - Nomad CSI volume provider, required for volume type 'csi'. - `-nomad-csi-volume-capacity-min=` - Nomad CSI volume capacity minimum, in bytes. - `-nomad-csi-volume-capacity-max=` - Nomad CSI volume capacity maximum, in bytes. diff --git a/website/content/commands/server-install.mdx b/website/content/commands/server-install.mdx index 922e902f5f6..378249cd6b5 100644 --- a/website/content/commands/server-install.mdx +++ b/website/content/commands/server-install.mdx @@ -121,7 +121,6 @@ and disable the UI, the command would be: - `-nomad-consul-domain=` - The domain where Consul is located. - `-nomad-consul-token=` - If set, the passed Consul token is stored in the job before sending to the Nomad servers. Overrides the CONSUL_HTTP_TOKEN environment variable if set. - `-nomad-host-volume=` - Nomad host volume name, required for volume type 'host'. -- `-nomad-host-volume-path=` - Path of the host volume for Waypoint on the Nomad client. - `-nomad-csi-volume-provider=` - Nomad CSI volume provider, required for volume type 'csi'. - `-nomad-csi-volume-capacity-min=` - Nomad CSI volume capacity minimum, in bytes. - `-nomad-csi-volume-capacity-max=` - Nomad CSI volume capacity maximum, in bytes.