Error creating a CSI volume in GCP (need 1 zone)

Hello, I’m trying to configure Nomad 1.1.2 to create a disk as CSI storage in GCP but I can’t configure the topology zone.

I’m reviewing the documentation and can’t find anything about this.

nomad volume create test.hcl

Error creating volume: Unexpected response code: 500 (rpc error: 1 error occurred:
        * controller create volume: CSI.ControllerCreateVolume: volume "test-csi" snapshot source &{"" ""} is not compatible with these parameters: rpc error: code = InvalidArgument desc = CreateVolume failed to pick zones for disk: failed to pick zones from topology: need 1 zones from topology, only got 0 unique zones

I tried to add these parameters in the volume file.

accessibility_requirements = "europe-west1-b"
accessibility = "europe-west1-b"
zone = "europe-west1-b"
accessible_topology = "europe-west1-b"
topology = "europe-west1-b"
topologykeyzone = "europe-west1-b"
topology.gke.io/zone = "europe-west1-b"

Volume file (test.hcl):

type      = "csi"
plugin_id = "gce-pd"
id        = "test-csi"
name      = "test-csi"

capacity_min = "10GiB"
capacity_max = "20GiB"

capability {
        access_mode = "single-node-writer"
        attachment_mode = "file-system"
}

parameters {

       [...]

}

Thanks!

I’m using this image version gcr.io/gke-release/gcp-compute-persistent-disk-csi-driver:v1.2.2-gke.2

Controller and node job:

job "gce-pd-csi-plugin" {

	type = "system"

	group "controller" {

		task "plugin" {

			driver = "docker"

			env {

				GOOGLE_APPLICATION_CREDENTIALS	= "/secrets/creds.json"

			}

			config {

				image = "gcr.io/gke-release/gcp-compute-persistent-disk-csi-driver:v1.2.2-gke.2"

				args = [

					"--endpoint=unix:///csi/csi.sock",
					"--v=6",
					"--logtostderr",
					"--run-node-service=false"

				]

			}

			csi_plugin {

				id        = "gce-pd"
				type      = "controller"
				mount_dir = "/csi"

			}

			resources {

				memory = 256

			}
		}

	}

	group "node" {

		task "plugin" {

			driver = "docker"

			env {

				GOOGLE_APPLICATION_CREDENTIALS = "/secrets/creds.json"

			}

			config {

				image = "gcr.io/gke-release/gcp-compute-persistent-disk-csi-driver:v1.2.2-gke.2"

				args = [
					"-endpoint=unix:///csi/csi.sock",
					"-v=6",
					"-logtostderr",
					"-run-controller-service=false"
				]

				privileged = true

			}

			csi_plugin {

				id        = "gce-pd"
				type      = "node"
				mount_dir = "/csi"

			}

			resources {

				memory = 256

			}
		}
	}

}

@rgonzlz I was having the same issue. Hashicorp nomad documentation is not useful at all for GCP. No clear example for GCP. So I found an issue from hashicorp team here CSI: volume spec should support HCL2 variables · Issue #12135 · hashicorp/nomad · GitHub and use GCP topology gcp-compute-persistent-disk-csi-driver/README.md at master · kubernetes-sigs/gcp-compute-persistent-disk-csi-driver · GitHub

So my volume.hcl is:

namespace    = "xxx"
id           = "xxxx"
name         = "xxxx"
type         = "csi"
plugin_id    = "gcepd"
capacity_max = "5G"
capacity_min = "5G"

capability {
  access_mode     = "single-node-writer"
  attachment_mode = "file-system"
}

mount_options {
  fs_type     = "xfs"
  mount_flags = [ "noatime", ]
}

topology_request {
  preferred {
    topology { 
      
      segments { 
        "topology.gke.io/zone" = "europe-west1-b"
      }
      
      segments { 
        "topology.gke.io/zone" = "europe-west1-c"
      }
      
      segments { 
        "topology.gke.io/zone" = "europe-west1-d"
      }
      
    }
  }
}

parameters {

  replication-type = "regional-pd"

  type = "pd-balanced"

}

Result:

nomad volume create render_volume.nomad
Created external volume projects/xxxx/regions/xxxx/disks/xxxx with ID xxxx

I guess this will help a lot of us :sunglasses: