-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
130 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: BUSL-1.1 | ||
|
||
set -xeuo pipefail | ||
|
||
nomad volume status -type=host -verbose | ||
nomad operator api /v1/nodes | jq '.[].HostVolumes' | ||
|
||
addr="$(nomad service info -json job | jq -r '.[0].Address'):8000" | ||
curl -sS "$addr/external/" | grep hi | ||
curl -sS "$addr/internal/" | grep hi | ||
|
||
echo '💚 looks good! 💚' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: BUSL-1.1 | ||
|
||
set -xeuo pipefail | ||
|
||
./setup.sh | ||
./check.sh | ||
./teardown.sh |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: BUSL-1.1 | ||
|
||
name = "external-plugin" | ||
type = "host" | ||
# the executable named `example-plugin-mkfs` must be placed in the | ||
# -host-volume-plugin-dir (config: client.host_volume_plugin_dir) | ||
# or you will get an error creating the volume: | ||
# * could not place volume "external-plugin": no node meets constraints | ||
# The default location is <data-dir>/host_volume_plugins | ||
plugin_id = "example-plugin-mkfs" | ||
capacity_min = "50mb" | ||
capacity_max = "50mb" | ||
|
||
capability { | ||
access_mode = "single-node-writer" | ||
attachment_mode = "file-system" | ||
} | ||
|
||
parameters { | ||
a = "ayy" | ||
} |
14 changes: 6 additions & 8 deletions
14
demo/hostvolume/host.volume.hcl → demo/hostvolume/internal-plugin.volume.hcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: BUSL-1.1 | ||
name = "test" | ||
type = "host" | ||
plugin_id = "example-host-volume" | ||
capacity_min = "50mb" | ||
capacity_max = "50mb" | ||
|
||
name = "internal-plugin" | ||
type = "host" | ||
# this plugin is built into Nomad; | ||
# it simply creates a directory. | ||
plugin_id = "mkdir" | ||
|
||
capability { | ||
access_mode = "single-node-writer" | ||
attachment_mode = "file-system" | ||
} | ||
|
||
parameters { | ||
a = "ayy" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: BUSL-1.1 | ||
|
||
job "job" { | ||
group "g" { | ||
task "t" { | ||
driver = "docker" | ||
config { | ||
image = "python:slim" | ||
command = "bash" | ||
args = ["-xc", <<-EOF | ||
for dir in internal external; do | ||
touch ${NOMAD_TASK_DIR}/$dir/hiii | ||
done | ||
python -m http.server -d ${NOMAD_TASK_DIR} --bind=:: | ||
EOF | ||
] | ||
ports = ["http"] | ||
} | ||
volume_mount { | ||
volume = "int" | ||
destination = "${NOMAD_TASK_DIR}/internal" | ||
} | ||
volume_mount { | ||
volume = "ext" | ||
destination = "${NOMAD_TASK_DIR}/external" | ||
} | ||
} | ||
volume "int" { | ||
type = "host" | ||
source = "internal-plugin" | ||
} | ||
volume "ext" { | ||
type = "host" | ||
source = "external-plugin" | ||
} | ||
network { | ||
port "http" { | ||
static = 8000 | ||
} | ||
} | ||
service { | ||
name = "job" | ||
port = "http" | ||
provider = "nomad" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: BUSL-1.1 | ||
|
||
set -xeuo pipefail | ||
|
||
nomad volume create external-plugin.volume.hcl | ||
nomad volume create internal-plugin.volume.hcl | ||
|
||
nomad job run job.nomad.hcl | ||
|
||
nomad volume status -type=host -verbose | ||
nomad operator api /v1/nodes | jq '.[].HostVolumes' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: BUSL-1.1 | ||
|
||
set -xeuo pipefail | ||
|
||
nomad job stop job || true | ||
|
||
for _ in {1..5}; do | ||
sleep 3 | ||
ids="$(nomad volume status -type=host -verbose | awk '/ternal-plugin/ {print$1}')" | ||
test -z "$ids" && break | ||
for id in $ids; do | ||
nomad volume delete -type=host "$id" || continue | ||
done | ||
done | ||
|