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

core/install: Add --nomad-csi-volume-name flag to install #3546

Merged
merged 8 commits into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
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 @@ -43,6 +43,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"`
CsiVolumeName string `hcl:"nomad_csi_volume_name,optional"`
demophoon marked this conversation as resolved.
Show resolved Hide resolved

NomadHost string `hcl:"nomad_host,optional"`
}
Expand Down Expand Up @@ -73,13 +74,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.CsiVolumeName == "" {
i.Config.CsiVolumeName = 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.CsiVolumeName,
paladin-devops marked this conversation as resolved.
Show resolved Hide resolved
i.Config.CsiPluginId,
i.Config.CsiVolumeProvider,
i.Config.CsiFS,
Expand Down Expand Up @@ -284,6 +288,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-name",
Target: &i.Config.CsiVolumeName,
Usage: "The name of the volume to initialize within the CSI provider.",
demophoon marked this conversation as resolved.
Show resolved Hide resolved
})
}

func (i *NomadRunnerInstaller) Uninstall(ctx context.Context, opts *InstallOpts) error {
Expand Down
26 changes: 25 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"`
csiVolumeName string `hcl:"nomad_csi_volume_name,optional"`
demophoon marked this conversation as resolved.
Show resolved Hide resolved
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"`
runnerCsiVolumeName string `hcl:"runner_csi_volume_name,optional"`
}

var (
Expand Down Expand Up @@ -203,13 +205,16 @@ func (i *NomadInstaller) Install(
if i.config.hostVolume != "" {
return nil, fmt.Errorf("choose either CSI or host volume, not both")
}
if i.config.csiVolumeName == "" {
i.config.csiVolumeName = "waypoint-server"
}

s.Update("Creating persistent volume")
err = nomad.CreatePersistentVolume(
ctx,
client,
"waypoint-server",
"waypoint-server",
i.config.csiVolumeName,
i.config.csiPluginId,
i.config.csiVolumeProvider,
i.config.csiFS,
Expand Down Expand Up @@ -642,6 +647,7 @@ func (i *NomadInstaller) InstallRunner(
CsiExternalId: i.config.csiExternalId,
CsiPluginId: i.config.csiPluginId,
CsiSecrets: i.config.csiSecrets,
CsiVolumeName: i.config.runnerCsiVolumeName,
NomadHost: i.config.nomadHost,
},
}
Expand Down Expand Up @@ -1159,6 +1165,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-name",
Target: &i.config.runnerCsiVolumeName,
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 +1307,12 @@ 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-name",
Target: &i.config.csiVolumeName,
Usage: "The name of the volume to initialize for Waypoint server within the CSI provider.",
})
}

func (i *NomadInstaller) UpgradeFlags(set *flag.Set) {
Expand Down Expand Up @@ -1394,6 +1412,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-name",
Target: &i.config.runnerCsiVolumeName,
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-name=<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-name=<string>` - The name of the volume to initialize for Waypoint server within the CSI provider.

@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-name=<string>` - The name of the volume to initialize within the CSI provider.

@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-name=<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-name=<string>` - The name of the volume to initialize for Waypoint server within the CSI provider.

@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 @@ -84,6 +84,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-name=<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