github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/demo/csi/hostpath/run.sh (about)

     1  #!/usr/bin/env bash
     2  # Run the hostpath plugin and create some volumes, and then claim them.
     3  set -e
     4  
     5  DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
     6  VOLUME_BASE_NAME=test-volume
     7  
     8  run_plugin() {
     9      local expected
    10      expected=$(nomad node status | grep -cv ID)
    11      echo "$ nomad job run ./plugin.nomad"
    12      nomad job run "${DIR}/plugin.nomad"
    13  
    14      while :
    15      do
    16          nomad plugin status hostpath \
    17              | grep "Nodes Healthy        = $expected" && break
    18          sleep 2
    19      done
    20      echo
    21      echo "$ nomad plugin status hostpath"
    22      nomad plugin status hostpath
    23  }
    24  
    25  create_volumes() {
    26      echo
    27      echo "$ cat hostpath.hcl | sed | nomad volume create -"
    28      sed -e "s/VOLUME_NAME/${VOLUME_BASE_NAME}[0]/" \
    29          "${DIR}/hostpath.hcl" | nomad volume create -
    30  
    31      echo
    32      echo "$ cat hostpath.hcl | sed | nomad volume create -"
    33      sed -e "s/VOLUME_NAME/${VOLUME_BASE_NAME}[1]/" \
    34          "${DIR}/hostpath.hcl" | nomad volume create -
    35  }
    36  
    37  claim_volumes() {
    38      echo
    39      echo "$ nomad job run ./redis.nomad"
    40      nomad job run "${DIR}/redis.nomad"
    41  }
    42  
    43  show_status() {
    44      echo
    45      echo "$ nomad volume status"
    46      nomad volume status
    47  }
    48  
    49  run_plugin
    50  create_volumes
    51  claim_volumes
    52  show_status