SynologyOpenSource / synology-csi

Apache License 2.0
506 stars 110 forks source link

nomad volume creation works, but not useable #20

Open mabunixda opened 2 years ago

mabunixda commented 2 years ago

The creation of a storage does work, but there is still some problem with the access mode within nomad:

$ nomad volume  status
Container Storage Interface
ID    Name  Plugin ID     Schedulable  Access Mode
test  test  synology true         <none>

my current configuration for the nomad csi plugin job is like this

job "plugin-synology" {
  type = "system"
  group "controller" {
    task "plugin" {
      driver = "docker"
      config {
        image = "docker.io/synology/synology-csi:v1.0.0"
        privileged = true
        volumes = [
          "local/csi.yaml:/etc/csi.yaml",
          "/:/host",
        ]
        args = [
          "--endpoint",
          "unix://csi/csi.sock",
          "--client-info",
          "/etc/csi.yaml",
        ]
      }
      template {
          destination = "local/csi.yaml"
          data = <<EOF
---
clients:
- host: 192.168.1.2
  port: 8443
  https: true
  username: nomad
  password: <password>
EOF
      }
      csi_plugin {
        id        = "synology"
        type      = "monolith"
        mount_dir = "/csi"
      }
      resources {
        cpu    = 256
        memory = 256
      }
    }
  }
}

and the volume definition for the nomad volume create is like

id        = "test"
name      = "test"
type      = "csi"
plugin_id = "synology"

capacity_min = "1GiB"
capacity_max = "2GiB"

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

mount_options {
  mount_flags = ["rw"]
}

Originally posted by @mabunixda in https://github.com/SynologyOpenSource/synology-csi/issues/14#issuecomment-1015232999

johnnyplaydrums commented 2 years ago

I shared a response to this in the other issue. Hope it's helpful: https://github.com/SynologyOpenSource/synology-csi/issues/14#issuecomment-1015568068

chihyuwu commented 2 years ago

Hi @mabunixda, There's no problem with your volume configuration. (That means, putting access_mode and attachment_mode inside the capability is the correct way for the latest Nomad.) It's an expected behavior that the access mode of a volume shows <none> before any job claimed it or after all jobs released it.

And for your csi plugin job configuration, I made the following changes:

  1. Add datacenters = ["dc1"] to job
  2. Add network_mode = "host" to task.config
    task "plugin" {
      driver = "docker"
      config {
        image = "docker.io/synology/synology-csi:v1.0.0"
        privileged = true
    +       network_mode = "host"
        volumes = [
          ....
        ]

    Then ran it on Nomad v1.3.1, did nomad volume create and ran my jobs, everything worked well.

If you failed to mount the csi volume into your job, missing network_mode = "host" might be the reason.

awanaut commented 11 months ago

I was able to get this working. Check here: https://github.com/SynologyOpenSource/synology-csi/issues/14#issuecomment-1795059676