github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/demo/csi/kadalu-csi/controller.nomad (about) 1 variable "cn_network" { 2 default = "dc1" 3 description = "Data Ceneter that the job needs to be run in" 4 } 5 6 variable "volname" { 7 default = "sample-pool" 8 description = "Volume name for Kadalu CSI which is used for all PVC creations purposes" 9 } 10 11 variable "gluster_hosts" { 12 default = "ghost.example.com" 13 14 description = <<-EOS 15 - External gluster host where the gluster volume is created, started and quota is set 16 - Multiple hosts can be supplied like "host1,host2,host3" (no spaces and trimmed endings) 17 - Prefer to supply only one or else need to supply the same wherever interpolation is not supported (ex: in volume.hcl files) 18 EOS 19 } 20 21 variable "gluster_volname" { 22 default = "dist" 23 description = "Gluster volume name in external cluster" 24 } 25 26 variable "kadalu_version" { 27 default = "0.8.15" 28 description = "Kadalu CSI version which is tested against Nomad version mentioned in README.md" 29 } 30 31 variable "gluster_user" { 32 default = "root" 33 description = "Remote user in external gluster cluster who has privileges to run gluster cli" 34 } 35 36 variable "ssh_priv_path" { 37 default = "~/.ssh/id_rsa" 38 39 description = <<-EOS 40 - Path to SSH private key which is used to connect to external gluster 41 - Needed only if gluster native quota capabilities is needed 42 - If not needed all corresponding SSH related info should be removed from this Job 43 - However it is highly recommended to supply SSH Private key for utilizing on the fly PVC expansion capabilities even with external gluster cluster 44 - SSH Key will only be used to perform two ops: set quota and change quota 45 - Please refer https://kadalu.io/rfcs/0007-Using-GlusterFS-directory-quota-for-external-gluster-volumes.html for more info 46 EOS 47 } 48 49 locals { 50 ssh_priv_key = "${file("${pathexpand("${var.ssh_priv_path}")}")}" 51 } 52 53 job "kadalu-csi-controller" { 54 datacenters = ["${var.cn_network}"] 55 type = "service" 56 57 group "controller" { 58 task "kadalu-controller" { 59 driver = "docker" 60 61 template { 62 # This is basically a JSON file which is used to connect to external gluster 63 # Make sure it follows JSON convention (No comma ',' for last key pair) 64 data = <<-EOS 65 { 66 "volname": "${var.volname}", 67 "volume_id": "${uuidv5("dns", "${var.volname}.kadalu.io")}", 68 "type": "External", 69 "pvReclaimPolicy": "delete", 70 "kadalu_format": "native", 71 "gluster_hosts": "${var.gluster_hosts}", 72 "gluster_volname": "${var.gluster_volname}", 73 "gluster_options": "log-level=DEBUG" 74 } 75 EOS 76 77 destination = "${NOMAD_TASK_DIR}/${var.volname}.info" 78 change_mode = "noop" 79 } 80 81 template { 82 data = "${uuidv5("dns", "kadalu.io")}" 83 destination = "${NOMAD_TASK_DIR}/uid" 84 change_mode = "noop" 85 } 86 87 template { 88 data = "${local.ssh_priv_key}" 89 destination = "${NOMAD_SECRETS_DIR}/ssh-privatekey" 90 change_mode = "noop" 91 perms = "600" 92 } 93 94 template { 95 # No need to supply 'SECRET_XXX' key if not using gluster native quota 96 data = <<-EOS 97 NODE_ID = "${node.unique.name}" 98 CSI_ENDPOINT = "unix://csi/csi.sock" 99 SECRET_GLUSTERQUOTA_SSH_USERNAME = "${var.gluster_user}" 100 KADALU_VERSION = "${var.kadalu_version}" 101 CSI_ROLE = "controller" 102 VERBOSE = "yes" 103 EOS 104 105 destination = "${NOMAD_TASK_DIR}/file.env" 106 env = true 107 } 108 109 config { 110 image = "docker.io/kadalu/kadalu-csi:${var.kadalu_version}" 111 112 # Nomad client config for docker plugin should have privileged set to 'true' 113 # refer https://www.nomadproject.io/docs/drivers/docker#privileged 114 # Need to access '/dev/fuse' for mounting external gluster volume 115 privileged = true 116 117 mount { 118 # Analogous to kadalu-info configmap 119 type = "bind" 120 121 # Make sure the source paths starts with current dir (basically: "./") 122 source = "./${NOMAD_TASK_DIR}/${var.volname}.info" 123 124 target = "/var/lib/gluster/${var.volname}.info" 125 readonly = true 126 } 127 128 mount { 129 # Extra baggage for now, will be taken care in Kadalu in next release 130 type = "bind" 131 source = "./${NOMAD_TASK_DIR}/uid" 132 target = "/var/lib/gluster/uid" 133 readonly = true 134 } 135 136 mount { 137 # If you are not using gluster native quota comment out this stanza 138 type = "bind" 139 source = "./${NOMAD_SECRETS_DIR}/ssh-privatekey" 140 target = "/etc/secret-volume/ssh-privatekey" 141 readonly = true 142 } 143 144 mount { 145 # Logging 146 type = "tmpfs" 147 target = "/var/log/gluster" 148 readonly = false 149 150 tmpfs_options { 151 # 1 MB 152 size = 1000000 # size in bytes 153 } 154 } 155 } 156 157 csi_plugin { 158 id = "kadalu-csi" 159 type = "controller" 160 mount_dir = "/csi" 161 } 162 } 163 } 164 }