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 #3546 from hashicorp/bugfix/main/csi-volume-name-flag
Browse files Browse the repository at this point in the history
core/install: Add --nomad-csi-volume-name flag to install
  • Loading branch information
demophoon authored Jul 29, 2022
2 parents 2d06a43 + 819d3ac commit a2389ee
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .changelog/3546.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```release-note:improvement
CLI: Nomad CSI volumes names can be specified during installation and upgrades for both Waypoint runners and Waypoint server installations
```

14 changes: 12 additions & 2 deletions internal/runnerinstall/nomad.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type NomadConfig struct {
CsiExternalId string `hcl:"nomad_csi_external_id,optional"`
CsiPluginId string `hcl:"nomad_csi_plugin_id,required"`
CsiSecrets map[string]string `hcl:"nomad_csi_secrets,optional"`
CsiVolume string `hcl:"nomad_csi_volume,optional"`

NomadHost string `hcl:"nomad_host,optional"`
}
Expand Down Expand Up @@ -74,13 +75,16 @@ func (i *NomadRunnerInstaller) Install(ctx context.Context, opts *InstallOpts) e
if i.Config.HostVolume != "" {
return fmt.Errorf("choose either CSI or host volume, not both")
}
if i.Config.CsiVolume == "" {
i.Config.CsiVolume = defaultRunnerName(opts.Id)
}

s = sg.Add("Creating persistent volume")
err = nomadutil.CreatePersistentVolume(
ctx,
client,
"waypoint-"+opts.Id+"-runner",
"waypoint-"+opts.Id+"-runner",
defaultRunnerName(opts.Id),
i.Config.CsiVolume,
i.Config.CsiPluginId,
i.Config.CsiVolumeProvider,
i.Config.CsiFS,
Expand Down Expand Up @@ -285,6 +289,12 @@ func (i *NomadRunnerInstaller) InstallFlags(set *flag.Set) {
Target: &i.Config.CsiSecrets,
Usage: "Credentials for publishing volume for Waypoint runner.",
})

set.StringVar(&flag.StringVar{
Name: "nomad-csi-volume",
Target: &i.Config.CsiVolume,
Usage: fmt.Sprintf("The name of the volume to initialize within the CSI provider. The default is %s.", defaultRunnerName("[runner_id]")),
})
}

func (i *NomadRunnerInstaller) Uninstall(ctx context.Context, opts *InstallOpts) error {
Expand Down
24 changes: 23 additions & 1 deletion internal/serverinstall/nomad.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type nomadConfig struct {
csiTopologies map[string]string `hcl:"nomad_csi_topologies,optional"`
csiSecrets map[string]string `hcl:"nomad_csi_secrets,optional"`
csiParams map[string]string `hcl:"csi_parameters,optional"`
csiVolume string `hcl:"nomad_csi_volume,optional"`
nomadHost string `hcl:"nomad_host,optional"`

runnerResourcesCPU string `hcl:"runner_resources_cpu,optional"`
Expand All @@ -75,6 +76,7 @@ type nomadConfig struct {
runnerCsiVolumeProvider string `hcl:"runner_csi_volume_provider,optional"`
runnerCsiVolumeCapacityMin int64 `hcl:"runner_csi_volume_capacity_min,optional"`
runnerCsiVolumeCapacityMax int64 `hcl:"runner_csi_volume_capacity_max,optional"`
runnerCsiVolume string `hcl:"runner_csi_volume,optional"`
}

var (
Expand Down Expand Up @@ -209,7 +211,7 @@ func (i *NomadInstaller) Install(
ctx,
client,
"waypoint-server",
"waypoint-server",
i.config.csiVolume,
i.config.csiPluginId,
i.config.csiVolumeProvider,
i.config.csiFS,
Expand Down Expand Up @@ -642,6 +644,7 @@ func (i *NomadInstaller) InstallRunner(
CsiExternalId: i.config.csiExternalId,
CsiPluginId: i.config.csiPluginId,
CsiSecrets: i.config.csiSecrets,
CsiVolume: i.config.runnerCsiVolume,
NomadHost: i.config.nomadHost,
},
}
Expand Down Expand Up @@ -1159,6 +1162,12 @@ func (i *NomadInstaller) InstallFlags(set *flag.Set) {
Usage: "Name of the CSI volume provider to use for the Waypoint runner.",
})

set.StringVar(&flag.StringVar{
Name: "nomad-runner-csi-volume",
Target: &i.config.runnerCsiVolume,
Usage: "The name of the volume to initialize for the Waypoint runner within the CSI provider.",
})

// TODO: Update default values for runner - less space is needed for runner compared to server
set.Int64Var(&flag.Int64Var{
Name: "nomad-runner-csi-volume-capacity-min",
Expand Down Expand Up @@ -1295,6 +1304,13 @@ func (i *NomadInstaller) InstallFlags(set *flag.Set) {
Target: &i.config.csiTopologies,
Usage: "Locations from which the Nomad Volume will be accessible.",
})

set.StringVar(&flag.StringVar{
Name: "nomad-csi-volume",
Target: &i.config.csiVolume,
Usage: "The name of the volume to initialize for Waypoint server within the CSI provider.",
Default: "waypoint-server",
})
}

func (i *NomadInstaller) UpgradeFlags(set *flag.Set) {
Expand Down Expand Up @@ -1394,6 +1410,12 @@ func (i *NomadInstaller) UpgradeFlags(set *flag.Set) {
Usage: "Name of the CSI volume provider to use for the Waypoint runner.",
})

set.StringVar(&flag.StringVar{
Name: "nomad-runner-csi-volume",
Target: &i.config.runnerCsiVolume,
Usage: "The name of the volume to initialize for the Waypoint runner within the CSI provider.",
})

// TODO: Update default values for runner - less space is needed for runner compared to server
set.Int64Var(&flag.Int64Var{
Name: "nomad-runner-csi-volume-capacity-min",
Expand Down
2 changes: 2 additions & 0 deletions website/content/commands/install.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ and disable the UI, the command would be:
- `-nomad-runner-memory=<string>` - MB of Memory to allocate to the runner job task. The default is 600.
- `-nomad-runner-host-volume=<string>` - Name of the host volume to use for the Waypoint runner.
- `-nomad-runner-csi-volume-provider=<string>` - Name of the CSI volume provider to use for the Waypoint runner.
- `-nomad-runner-csi-volume=<string>` - The name of the volume to initialize for the Waypoint runner within the CSI provider.
- `-nomad-runner-csi-volume-capacity-min=<int>` - Waypoint runner Nomad CSI volume capacity minimum, in bytes. The default is 1073741824.
- `-nomad-runner-csi-volume-capacity-max=<int>` - Waypoint runner Nomad CSI volume capacity maximum, in bytes. The default is 2147483648.
- `-nomad-server-image=<string>` - Docker image for the Waypoint server. The default is hashicorp/waypoint:latest.
Expand All @@ -135,5 +136,6 @@ and disable the UI, the command would be:
- `-nomad-csi-plugin-id=<string>` - The ID of the CSI plugin that manages the volume, required for volume type 'csi'.
- `-nomad-csi-external-id=<string>` - The ID of the physical volume from the Nomad storage provider.
- `-nomad-csi-topologies=<key=value>` - Locations from which the Nomad Volume will be accessible.
- `-nomad-csi-volume=<string>` - The name of the volume to initialize for Waypoint server within the CSI provider. The default is waypoint-server.

@include "commands/install_more.mdx"
1 change: 1 addition & 0 deletions website/content/commands/runner-install.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,6 @@ unless the '-skip-adopt' flag is set to true.
- `-nomad-csi-topologies=<key=value>` - Locations from which the Nomad Volume will be accessible.
- `-nomad-csi-external-id=<string>` - The ID of the physical volume from the Nomad storage provider.
- `-nomad-csi-secrets=<key=value>` - Credentials for publishing volume for Waypoint runner.
- `-nomad-csi-volume=<string>` - The name of the volume to initialize within the CSI provider. The default is waypoint-[runner_id]-runner.

@include "commands/runner-install_more.mdx"
2 changes: 2 additions & 0 deletions website/content/commands/server-install.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ and disable the UI, the command would be:
- `-nomad-runner-memory=<string>` - MB of Memory to allocate to the runner job task. The default is 600.
- `-nomad-runner-host-volume=<string>` - Name of the host volume to use for the Waypoint runner.
- `-nomad-runner-csi-volume-provider=<string>` - Name of the CSI volume provider to use for the Waypoint runner.
- `-nomad-runner-csi-volume=<string>` - The name of the volume to initialize for the Waypoint runner within the CSI provider.
- `-nomad-runner-csi-volume-capacity-min=<int>` - Waypoint runner Nomad CSI volume capacity minimum, in bytes. The default is 1073741824.
- `-nomad-runner-csi-volume-capacity-max=<int>` - Waypoint runner Nomad CSI volume capacity maximum, in bytes. The default is 2147483648.
- `-nomad-server-image=<string>` - Docker image for the Waypoint server. The default is hashicorp/waypoint:latest.
Expand All @@ -135,5 +136,6 @@ and disable the UI, the command would be:
- `-nomad-csi-plugin-id=<string>` - The ID of the CSI plugin that manages the volume, required for volume type 'csi'.
- `-nomad-csi-external-id=<string>` - The ID of the physical volume from the Nomad storage provider.
- `-nomad-csi-topologies=<key=value>` - Locations from which the Nomad Volume will be accessible.
- `-nomad-csi-volume=<string>` - The name of the volume to initialize for Waypoint server within the CSI provider. The default is waypoint-server.

@include "commands/server-install_more.mdx"
1 change: 1 addition & 0 deletions website/content/commands/server-upgrade.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ manually installed runners will not be automatically upgraded.
- `-nomad-runner-memory=<string>` - MB of Memory to allocate to the runner job task. The default is 600.
- `-nomad-runner-host-volume=<string>` - Name of the host volume to use for the Waypoint runner.
- `-nomad-runner-csi-volume-provider=<string>` - Name of the CSI volume provider to use for the Waypoint runner.
- `-nomad-runner-csi-volume=<string>` - The name of the volume to initialize for the Waypoint runner within the CSI provider.
- `-nomad-runner-csi-volume-capacity-min=<int>` - Waypoint runner Nomad CSI volume capacity minimum, in bytes. The default is 1073741824.
- `-nomad-runner-csi-volume-capacity-max=<int>` - Waypoint runner Nomad CSI volume capacity maximum, in bytes. The default is 2147483648.
- `-nomad-server-image=<string>` - Docker image for the Waypoint server. The default is hashicorp/waypoint:latest.
Expand Down

0 comments on commit a2389ee

Please sign in to comment.