github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/demo/csi/kadalu-csi/nodeplugin.nomad (about)

     1  # Please refer 'controller.nomad' file for  variable and job descriptions
     2  variable "cn_network" {
     3    default = "dc1"
     4  }
     5  
     6  variable "volname" {
     7    default = "sample-pool"
     8  }
     9  
    10  variable "gluster_hosts" {
    11    default = "ghost.example.com"
    12  }
    13  
    14  variable "gluster_volname" {
    15    default = "dist"
    16  }
    17  
    18  variable "kadalu_version" {
    19    default = "0.8.15"
    20  }
    21  
    22  job "kadalu-csi-nodeplugin" {
    23    datacenters = ["${var.cn_network}"]
    24  
    25    # Should be running on every nomad client
    26    type = "system"
    27  
    28    update {
    29      stagger      = "5s"
    30      max_parallel = 1
    31    }
    32  
    33    group "nodeplugin" {
    34      task "kadalu-nodeplugin" {
    35        driver = "docker"
    36  
    37        template {
    38          data = <<-EOS
    39          {
    40              "volname": "${var.volname}",
    41              "volume_id": "${uuidv5("dns", "${var.volname}.kadalu.io")}",
    42              "type": "External",
    43              "pvReclaimPolicy": "delete",
    44              "kadalu_format": "native",
    45              "gluster_hosts": "${var.gluster_hosts}",
    46              "gluster_volname": "${var.gluster_volname}",
    47              "gluster_options": "log-level=DEBUG"
    48          }
    49          EOS
    50  
    51          destination = "${NOMAD_TASK_DIR}/${var.volname}.info"
    52          change_mode = "noop"
    53        }
    54  
    55        template {
    56          data        = "${uuidv5("dns", "kadalu.io")}"
    57          destination = "${NOMAD_TASK_DIR}/uid"
    58          change_mode = "noop"
    59        }
    60  
    61        template {
    62          data = <<-EOS
    63          NODE_ID        = "${node.unique.name}"
    64          CSI_ENDPOINT   = "unix://csi/csi.sock"
    65          KADALU_VERSION = "${var.kadalu_version}"
    66          CSI_ROLE       = "nodeplugin"
    67          VERBOSE        = "yes"
    68          EOS
    69  
    70          destination = "${NOMAD_TASK_DIR}/file.env"
    71          env         = true
    72        }
    73  
    74        config {
    75          image = "docker.io/kadalu/kadalu-csi:${var.kadalu_version}"
    76  
    77          privileged = true
    78  
    79          mount {
    80            type     = "bind"
    81            source   = "./${NOMAD_TASK_DIR}/${var.volname}.info"
    82            target   = "/var/lib/gluster/${var.volname}.info"
    83            readonly = true
    84          }
    85  
    86          mount {
    87            type     = "bind"
    88            source   = "./${NOMAD_TASK_DIR}/uid"
    89            target   = "/var/lib/gluster/uid"
    90            readonly = true
    91          }
    92  
    93          mount {
    94            type     = "tmpfs"
    95            target   = "/var/log/gluster"
    96            readonly = false
    97  
    98            tmpfs_options {
    99              size = 1000000
   100            }
   101          }
   102        }
   103  
   104        csi_plugin {
   105          id        = "kadalu-csi"
   106          type      = "node"
   107          mount_dir = "/csi"
   108        }
   109      }
   110    }
   111  }